v0.6.0
This release adds the driver databend, for Databend and its SQL. It also gives every driver the same options for one statement, and it adds the key auth to the drivers influxdb and neo4j. A caller of couchbase.Option needs no change.
The Databend driver
Import github.com/xo/dbimp/databend. It registers the name databend, and it takes a DSN of this form:
databend://user:password@host:port/database?key=value
The path is the database, and default without one. The port is 8000 without one, with tls=true too. The keys are tls, auth=basic|bearer, cancel=kill|none and timezone, and the driver refuses any other key, the keys sslmode, tenant and warehouse of databend-go too (D117).
These are the rules that a caller sees:
- The server binds each argument. A positional argument fills each
?in order, andsql.Named("k", v)fills:k. One statement cannot take both kinds. A decimal goes as a string, which keeps every digit, and a[]byteis refused (D120 and D124). - Every value arrives as text, and the driver decodes it by the type of its column:
int64,float64,*apd.Decimal,bool,[]byte,time.Timeandstring. AnArray, aMapand aTuplearrive as text of SQL, and the driver decodes them into[]anyand maps. AGeometryand aGeographyare WKT (D118 and D119). - A
Bitmapcannot be read, because the server writes none of its bytes in JSON. Reading one fails withdbimp.ErrNotSupported(D119). - Each result arrives one page at a time. When the context ends, or the rows close early, the driver kills the query on the server, because the server runs it on when the client leaves (D123).
BeginTxbegins a transaction, which the session of the connection carries. A DDL statement or any error ends it, andCommitthen returns why.USEandSETstay on the connection untildatabase/sqlhands it to another caller (D121 and D122).RowsAffectedis the count that the result names, such asnumber of rows inserted. A statement whose result names none, such asREPLACE INTO, returnsdbimp.ErrNotSupported(D125).
The tests passed against 1.2.881 and 1.2.948 as the administrator and as the ordinary user. docs/DATABEND.md holds what the driver knows about the server, and D117 to D125 in docs/decisions/ hold the reasons.
What changes for a caller
- All drivers. Each driver takes
WithTimeout,WithReadonly,WithParameterandWithDatabase, throughWithOptionsor as an argument of a statement, and an option for each key of its DSN that can change for one statement. An option that the server cannot honor fails the statement withdbimp.ErrNotSupported, and a value that the DSN would refuse fails it withdbimp.ErrInvalidValue.WithParameterreplaces a key that the driver sets itself (D109). - Couchbase.
couchbase.Optionis nowdbimp.Option[...], which stays source compatible.WithDatabasesetsquery_context, asWithQueryContextdoes. - Neo4j.
WithTimeoutsendsmaxExecutionTimein whole seconds, and fails withdbimp.ErrNotSupportedon a release before 2026.04, which ignores it.WithDatabaseandWithCancelare new. The keyauth=bearersends the password as a Bearer token (D116). - InfluxDB.
WithDatabase,WithRetentionPolicy,WithChunkedandWithDescribeare new.WithTimeoutandWithReadonlyfail withdbimp.ErrNotSupported, because no release has either for one request. The keyauth=bearersends the password as a token:Tokento InfluxDB 2, andBearerto 1 and 3 (D116). - ArangoDB.
WithTimeoutsendsmaxRuntime, andWithDatabase,WithBatchandWithCancelare new.WithReadonlyholds only in a read-only transaction. - SurrealDB.
WithDatabaseandWithNamespaceset the database and the namespace of one statement.WithTimeoutandWithReadonlyfail withdbimp.ErrNotSupported.
Other changes
- The root package holds the options of every driver:
Option,WithOptions,Resolve,UnsupportedandMarshalParams. It also holdsSetAuth, which sends the secret of a DSN as the keyauthsays. - The recorder of step 6 follows each page of a query, and escapes a captured value inside a JSON body.
TestEveryDriverTakesTheCommonOptionsholds the options of each driver.