MCPcopy
hub / github.com/pocketbase/pocketbase / NewQuery

Method NewQuery

core/db_builder.go:151–160  ·  view source on GitHub ↗

NewQuery implements the [dbx.Builder.NewQuery] interface method by routing the SELECT queries to the concurrent builder instance.

(str string)

Source from the content-addressed store, hash-verified

149// NewQuery implements the [dbx.Builder.NewQuery] interface method by
150// routing the SELECT queries to the concurrent builder instance.
151func (b *dualDBBuilder) NewQuery(str string) *dbx.Query {
152 // note: technically INSERT/UPDATE/DELETE could also have CTE but since
153 // it is rare for now this scase is ignored to avoid unnecessary complicating the checks
154 trimmed := trimLeftSpaces(str)
155 if hasPrefixFold(trimmed, "SELECT") || hasPrefixFold(trimmed, "WITH") {
156 return b.concurrentDB.NewQuery(str)
157 }
158
159 return b.nonconcurrentDB.NewQuery(str)
160}
161
162var asciiSpace = [256]uint8{'\t': 1, '\n': 1, '\v': 1, '\f': 1, '\r': 1, ' ': 1}
163

Callers 15

TestReloadSettingsFunction · 0.80
registerBaseHooksMethod · 0.80
TableColumnsMethod · 0.80
TableInfoMethod · 0.80
DeleteTableMethod · 0.80
vacuumMethod · 0.80
SyncRecordTableSchemaMethod · 0.80

Calls 2

trimLeftSpacesFunction · 0.85
hasPrefixFoldFunction · 0.85

Tested by 8

TestReloadSettingsFunction · 0.64
TestBaseAppDBDualBuilderFunction · 0.64
TestSQLRunFunction · 0.64