|
| 1 | +--- |
| 2 | +title: Driver Sql |
| 3 | +description: Driver Sql protocol schemas |
| 4 | +--- |
| 5 | + |
| 6 | +# Driver Sql |
| 7 | + |
| 8 | +<Callout type="info"> |
| 9 | +**Source:** `packages/spec/src/system/driver-sql.zod.ts` |
| 10 | +</Callout> |
| 11 | + |
| 12 | +## TypeScript Usage |
| 13 | + |
| 14 | +```typescript |
| 15 | +import { DataTypeMappingSchema, SQLDialectSchema, SQLDriverConfigSchema, SSLConfigSchema } from '@objectstack/spec/system'; |
| 16 | +import type { DataTypeMapping, SQLDialect, SQLDriverConfig, SSLConfig } from '@objectstack/spec/system'; |
| 17 | + |
| 18 | +// Validate data |
| 19 | +const result = DataTypeMappingSchema.parse(data); |
| 20 | +``` |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## DataTypeMapping |
| 25 | + |
| 26 | +### Properties |
| 27 | + |
| 28 | +| Property | Type | Required | Description | |
| 29 | +| :--- | :--- | :--- | :--- | |
| 30 | +| **text** | `string` | ✅ | SQL type for text fields (e.g., VARCHAR, TEXT) | |
| 31 | +| **number** | `string` | ✅ | SQL type for number fields (e.g., NUMERIC, DECIMAL, INT) | |
| 32 | +| **boolean** | `string` | ✅ | SQL type for boolean fields (e.g., BOOLEAN, BIT) | |
| 33 | +| **date** | `string` | ✅ | SQL type for date fields (e.g., DATE) | |
| 34 | +| **datetime** | `string` | ✅ | SQL type for datetime fields (e.g., TIMESTAMP, DATETIME) | |
| 35 | +| **json** | `string` | optional | SQL type for JSON fields (e.g., JSON, JSONB) | |
| 36 | +| **uuid** | `string` | optional | SQL type for UUID fields (e.g., UUID, CHAR(36)) | |
| 37 | +| **binary** | `string` | optional | SQL type for binary fields (e.g., BLOB, BYTEA) | |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +## SQLDialect |
| 42 | + |
| 43 | +### Allowed Values |
| 44 | + |
| 45 | +* `postgresql` |
| 46 | +* `mysql` |
| 47 | +* `sqlite` |
| 48 | +* `mssql` |
| 49 | +* `oracle` |
| 50 | +* `mariadb` |
| 51 | + |
| 52 | +--- |
| 53 | + |
| 54 | +## SQLDriverConfig |
| 55 | + |
| 56 | +### Properties |
| 57 | + |
| 58 | +| Property | Type | Required | Description | |
| 59 | +| :--- | :--- | :--- | :--- | |
| 60 | +| **name** | `string` | ✅ | Driver instance name | |
| 61 | +| **type** | `string` | ✅ | Driver type must be "sql" | |
| 62 | +| **capabilities** | `object` | ✅ | Driver capability flags | |
| 63 | +| **connectionString** | `string` | optional | Database connection string (driver-specific format) | |
| 64 | +| **poolConfig** | `object` | optional | Connection pool configuration | |
| 65 | +| **dialect** | `Enum<'postgresql' \| 'mysql' \| 'sqlite' \| 'mssql' \| 'oracle' \| 'mariadb'>` | ✅ | SQL database dialect | |
| 66 | +| **dataTypeMapping** | `object` | ✅ | SQL data type mapping configuration | |
| 67 | +| **ssl** | `boolean` | optional | Enable SSL/TLS connection | |
| 68 | +| **sslConfig** | `object` | optional | SSL/TLS configuration (required when ssl is true) | |
| 69 | + |
| 70 | +--- |
| 71 | + |
| 72 | +## SSLConfig |
| 73 | + |
| 74 | +### Properties |
| 75 | + |
| 76 | +| Property | Type | Required | Description | |
| 77 | +| :--- | :--- | :--- | :--- | |
| 78 | +| **rejectUnauthorized** | `boolean` | optional | Reject connections with invalid certificates | |
| 79 | +| **ca** | `string` | optional | CA certificate file path or content | |
| 80 | +| **cert** | `string` | optional | Client certificate file path or content | |
| 81 | +| **key** | `string` | optional | Client private key file path or content | |
| 82 | + |
0 commit comments