1- <!-- docs: sync from coderbuzz/codex@60ca8c4 -->
1+ <!-- docs: sync from coderbuzz/codex@643d093 -->
22
33# @coderbuzz/sql : AI Expert Knowledge Reference
44
@@ -13,7 +13,7 @@ package. Treat every rule here as authoritative.
1313## 1. Mental Model
1414
1515```
16- Dialect Namespace (sqlite / pg / mysql / mssql / ch / oracle / snowflake / databricks )
16+ Dialect Namespace (sqlite / pg / mysql / mssql / ch)
1717 ├── connect(config) → Engine instance (extends Sql<T>)
1818 ├── table(name, schema) → SqlTable<S>
1919 ├── column factories (integer, text, serial, uuid, ...)
@@ -50,9 +50,6 @@ import { pg as pgBun } from "@coderbuzz/sql/postgres-bun"; // driver: Bun built-
5050import { mysql } from " @coderbuzz/sql/mysql" ;
5151import { mssql } from " @coderbuzz/sql/mssql" ;
5252import { ch } from " @coderbuzz/sql/clickhouse" ;
53- import { oracle } from " @coderbuzz/sql/oracle" ;
54- import { snowflake } from " @coderbuzz/sql/snowflake" ;
55- import { databricks } from " @coderbuzz/sql/databricks" ;
5653```
5754
5855### 2.2 Root package: shared helpers and types
@@ -145,9 +142,6 @@ import * as sqliteTypes from "@coderbuzz/sql/sqlite-types";
145142import * as clickhouseTypes from " @coderbuzz/sql/clickhouse-types" ;
146143import * as mysqlTypes from " @coderbuzz/sql/mysql-types" ;
147144import * as mssqlTypes from " @coderbuzz/sql/mssql-types" ;
148- import * as oracleTypes from " @coderbuzz/sql/oracle-types" ;
149- import * as snowflakeTypes from " @coderbuzz/sql/snowflake-types" ;
150- import * as databricksTypes from " @coderbuzz/sql/databricks-types" ;
151145```
152146
153147---
@@ -220,32 +214,6 @@ const db = ch.connect({
220214 username: " default" ,
221215 password: " " ,
222216});
223-
224- // Oracle
225- const db = oracle .connect ({
226- user: " app" ,
227- password: " secret" ,
228- connectString: " localhost/XEPDB1" ,
229- poolMax: 10 ,
230- });
231-
232- // Snowflake
233- const db = snowflake .connect ({
234- account: " my-account" ,
235- username: " APP_USER" ,
236- password: " secret" ,
237- database: " APP_DB" ,
238- schema: " PUBLIC" ,
239- warehouse: " COMPUTE_WH" ,
240- role: " APP_ROLE" ,
241- });
242-
243- // Databricks
244- const db = databricks .connect ({
245- host: " adb-xxxx.azuredatabricks.net" ,
246- path: " /sql/1.0/warehouses/xxxx" ,
247- token: " dapi..." ,
248- });
249217```
250218
251219---
@@ -663,9 +631,6 @@ await events.insert(db)
663631| SQLite | ✓ | ✓ |
664632| MySQL | ✗ (throws) | ✗ (throws) |
665633| MSSQL | ✗ (throws) | ✗ (throws) |
666- | Oracle | ✗ (throws) | ✗ (throws) |
667- | Snowflake | ✗ (throws) | ✗ (throws) |
668- | Databricks | ✗ (throws) | ✗ (throws) |
669634| ClickHouse | ✗ (throws) | ✗ (throws) |
670635
671636---
@@ -779,7 +744,6 @@ Placeholder styles per dialect:
779744| PostgreSQL | ` $N ` | ` ... WHERE id = $1 ` |
780745| MySQL | ` ? ` | ` ... WHERE id = ? ` |
781746| MSSQL | ` @pN ` | ` ... WHERE id = @p1 ` |
782- | Oracle | ` :N ` | ` ... WHERE id = :1 ` |
783747| Others | ` ? ` | ` ... WHERE id = ? ` |
784748
785749---
@@ -836,7 +800,7 @@ tx.select("last_no").from("nomor_faktur").where({ seri: "A" }).forUpdate()
836800// .forShare(), .forUpdate({ noWait: true }), .forUpdate({ skipLocked: true })
837801```
838802
839- PostgreSQL / MySQL / Oracle only. SQLite, MSSQL and ClickHouse throw.
803+ PostgreSQL / MySQL only. SQLite, MSSQL and ClickHouse throw.
840804
841805### Errors
842806
@@ -964,49 +928,20 @@ ch.boolean() ch.date() ch.date32() ch.datetime() ch.datetime64(precision)
964928ch .uuid () ch .ipv4 () ch .ipv6 () ch .lowCardinality (type )
965929```
966930
967- ### Oracle
968-
969- ANSI types plus:
970-
971- ``` ts
972- oracle .number (p ? , s ? ) oracle .varchar2 (n ) oracle .clob ()
973- oracle .blob () oracle .date () oracle .timestamp_tz (precision )
974- // Note: oracle.date() is exported as `oracleDate` from the namespace
975- // to avoid collision with ANSI `date`
976- ` ` `
977-
978- ### Snowflake
979-
980- ANSI types plus:
981-
982- ` ` ` ts
983- snowflake .variant <T >() snowflake .timestamp_ntz (precision )
984- snowflake .timestamp_ltz (precision ) snowflake .array_type <T >()
985- snowflake .object_type <T >()
986- ` ` `
987-
988- ### Databricks
989-
990- ` ` ` ts
991- databricks .string () databricks .long () databricks .double ()
992- databricks .struct <T >(fields ) databricks .map_type <K , V >() databricks .array_type <T >()
993- ` ` `
994-
995931---
996932
997933## 19. Dialect-Specific Behaviors
998934
999935| Behavior | Details |
1000936| --------------------------- | ----------------------------------------------------------------------------------------------------------- |
1001- | **Identifier quoting** | ` " id" ` (PG, SQLite, Oracle, Snowflake ) · ` ` ` id ` ` ` (MySQL, CH, Databricks ) · ` [id ]` (MSSQL) |
1002- | **Placeholders** | ` ? ` (SQLite/MySQL/CH/Snowflake/Databricks ) · ` $N ` (PG) · ` @pN ` (MSSQL) · ` : N ` (Oracle) |
937+ | ** Identifier quoting** | ` "id" ` (PG, SQLite) · `` `id` `` (MySQL, CH) · ` [id] ` (MSSQL) |
938+ | ** Placeholders** | ` ? ` (SQLite/MySQL/CH) · ` $N ` (PG) · ` @pN ` (MSSQL) |
1003939| ** RETURNING** | PostgreSQL + SQLite only. Others throw ` "RETURNING is not supported by this dialect" ` |
1004940| ** FULL OUTER JOIN** | PostgreSQL + ANSI only. SQLite/MySQL/ClickHouse throw at compile time |
1005941| ** ClickHouse params** | Values inlined into SQL (HTTP API has no native binding). Safe via ` escapeClickHouseValue() ` |
1006942| ** ClickHouse CREATE INDEX** | Not emitted. Indexes are defined via the ENGINE / ORDER BY clause |
1007943| ** ClickHouse UNIQUE** | Not supported. Throws if ` .unique() ` is used in a ClickHouse table |
1008944| ** MSSQL LIMIT** | Renders as ` OFFSET n ROWS FETCH NEXT m ROWS ONLY ` . Injects ` ORDER BY (SELECT NULL) ` when no ORDER BY exists |
1009- | **Oracle LIMIT** | Same ` OFFSET / FETCH ` syntax as MSSQL |
1010945| ** MySQL SERIAL** | ` SERIAL ` primary key becomes ` INT AUTO_INCREMENT ` in DDL |
1011946| ** SQLite WAL** | ` PRAGMA journal_mode = WAL ` applied automatically for file-based DB |
1012947| ** SQLite streaming** | Uses ` bun:sqlite ` synchronous ` stmt.iterate() ` |
@@ -1083,7 +1018,7 @@ result.statistics?.read_rows; // optional stats
10831018
10841019| Error message | When it occurs |
10851020| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------- |
1086- | ` " RETURNING is not supported by this dialect" ` | ` .returning ()` called on MySQL/MSSQL/Oracle/Snowflake/Databricks/ ClickHouse and ` .toSQL ()` called |
1021+ | ` "RETURNING is not supported by this dialect" ` | ` .returning() ` called on MySQL/MSSQL/ClickHouse and ` .toSQL() ` called |
10871022| ` "SQLite does not support FULL OUTER JOIN" ` | ` .full_join() ` used with SQLite compiler |
10881023| ` "MySQL does not support FULL OUTER JOIN" ` | ` .full_join() ` used with MySQL compiler |
10891024| ` "ClickHouse does not support FULL OUTER JOIN" ` | ` .full_join() ` used with ClickHouse compiler |
@@ -1107,11 +1042,10 @@ const rows = await db.execute(`SELECT * FROM users WHERE name = '${name}'`);
11071042const rows = await db .sql ` SELECT * FROM users WHERE name = ${name } ` .execute ();
11081043```
11091044
1110- **DO NOT** call ` .stream ()` or ` .prepare ()` on MySQL, MSSQL, Oracle, Snowflake,
1111- Databricks, or ClickHouse engines: they throw.
1045+ ** DO NOT** call ` .stream() ` or ` .prepare() ` on MySQL, MSSQL, or ClickHouse
1046+ engines: they throw.
11121047
1113- **DO NOT** use ` .returning ()` on MySQL, MSSQL, Oracle, Snowflake, Databricks, or
1114- ClickHouse: throws ` " RETURNING is not supported by this dialect" ` .
1048+ ** DO NOT** use ` .returning() ` on MySQL, MSSQL, or ClickHouse: throws ` "RETURNING is not supported by this dialect" ` .
11151049
11161050** DO NOT** use ` .full_join() ` with SQLite, MySQL, or ClickHouse: throws at
11171051compile time.
@@ -1533,7 +1467,7 @@ Package: @coderbuzz/sql
15331467Version : 0.1 .3
15341468License : MIT
15351469Type : ESM only (type : " module" )
1536- Peer deps (all optional): pg, mysql2, mssql, better-sqlite3, @db/sqlite, oracledb, snowflake-sdk, @databricks/sql
1470+ Peer deps (all optional ): pg , mysql2 , mssql , better - sqlite3 , @db / sqlite
15371471Runtime dep : @coderbuzz / veta (internal , schema coercion )
15381472` ` `
15391473
@@ -1549,15 +1483,9 @@ Runtime dep: @coderbuzz/veta (internal, schema coercion)
15491483| ` @coderbuzz / sql / mysql ` | ` mysql ` namespace + ` MySQLEngine ` |
15501484| ` @coderbuzz / sql / mssql ` | ` mssql ` namespace + ` MSSQLEngine ` |
15511485| ` @coderbuzz / sql / clickhouse ` | ` ch ` namespace + ` ClickHouseEngine ` |
1552- | ` @coderbuzz/sql/oracle ` | ` oracle ` namespace + ` OracleEngine ` |
1553- | ` @coderbuzz/sql/snowflake ` | ` snowflake ` + ` SnowflakeEngine ` |
1554- | ` @coderbuzz/sql/databricks ` | ` databricks ` + ` DatabricksEngine ` |
15551486| ` @coderbuzz / sql / sqlite - types ` | SQLite column factories only |
15561487| ` @coderbuzz / sql / postgres - types ` | PostgreSQL column factories only |
15571488| ` @coderbuzz / sql / mysql - types ` | MySQL column factories only |
15581489| ` @coderbuzz / sql / mssql - types ` | MSSQL column factories only |
15591490| ` @coderbuzz / sql / clickhouse - types ` | ClickHouse column factories only |
1560- | ` @coderbuzz/sql/oracle-types ` | Oracle column factories only |
1561- | ` @coderbuzz/sql/snowflake-types ` | Snowflake column factories only |
1562- | ` @coderbuzz/sql/databricks-types ` | Databricks column factories only |
15631491| ` @coderbuzz / sql / ansi ` | ANSI column factories only |
0 commit comments