Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta #2600

Merged
merged 54 commits into from
Jul 8, 2024
Merged

Beta #2600

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
ee97199
Fix RQB behavior for tables with same names in different schemas
dankochetov May 22, 2024
afa3ad2
Remove .only
dankochetov May 22, 2024
0f7a43f
Replace --loader with --import
dankochetov May 22, 2024
96b2775
Restore --loader
dankochetov May 22, 2024
c47a39e
Fix test script
dankochetov May 22, 2024
24bf24e
Fix test script
dankochetov May 22, 2024
77fd6f4
Increase memory for Ava integration tests
dankochetov May 23, 2024
d4cb9d5
Merge branch 'beta' into fix-rqb-tables-with-schema
dankochetov May 26, 2024
ff2808d
Update vitest script
dankochetov May 26, 2024
8325996
Rollback mysql2 version
dankochetov May 26, 2024
08351cd
Revert mysql2 version in drizzle-orm
dankochetov May 26, 2024
2aee411
Downgrade dependencies
dankochetov May 26, 2024
861bff7
Use self-hosted runner
dankochetov May 26, 2024
8f7ffa3
Update DB ports
dankochetov May 26, 2024
406c654
Rollback more deps
dankochetov May 26, 2024
82cc29e
Update lockfile
dankochetov May 26, 2024
13aca84
Rollback even more deps
dankochetov May 26, 2024
410f881
Sync deps versions
dankochetov May 26, 2024
53b9b57
Replace tsx with ts-node for integration tests
dankochetov May 26, 2024
09c17f8
Remove segfault-handler
dankochetov May 27, 2024
78b5b8b
WIP: update all tests to use vitest, extract common tests
dankochetov May 28, 2024
0b4d01d
Add Prisma driver via extension
dankochetov Jun 8, 2024
072a919
Add "prisma generate" to pipelines, fix tests
dankochetov Jun 8, 2024
defc394
Move prisma generate before build
dankochetov Jun 9, 2024
d588ac5
Fix Node version
dankochetov Jun 9, 2024
1836aa6
Fix linter issues
dankochetov Jun 9, 2024
edb228a
Add Prisma schema to src
dankochetov Jun 9, 2024
34ecbe5
Add missing extensions
dankochetov Jun 9, 2024
c59440c
Fix Prisma driver run result
dankochetov Jun 9, 2024
f9f4c2e
Implement get() for Prisma SQLite driver
dankochetov Jun 9, 2024
471ed1b
Merge pull request #2478 from drizzle-team/prisma-driver
dankochetov Jun 9, 2024
b1c8d15
Update dprint
dankochetov Jun 9, 2024
b59e0a5
Fix type hints generation for RDS Data API
dankochetov Jun 11, 2024
68b29a0
Updated:
ProvorovOleksii Jun 12, 2024
27ef493
Updated:
ProvorovOleksii Jun 24, 2024
5510c7e
Merge branch 'beta' of github.com:drizzle-team/drizzle-orm into fix-r…
AndriiSherman Jul 4, 2024
c795596
Update after merging beta
AndriiSherman Jul 4, 2024
f62de3e
Add mysql tests changes
AndriiSherman Jul 5, 2024
a42f2d7
Added base for sqlite common tests
ProvorovOleksii Jul 5, 2024
901958e
Merge branch 'fix-rqb-tables-with-schema' of github.com:drizzle-team/…
ProvorovOleksii Jul 5, 2024
1ba60ce
Updated:
ProvorovOleksii Jul 5, 2024
bb75eed
Fix mysql tests
AndriiSherman Jul 5, 2024
045e967
Merge branch 'fix-rqb-tables-with-schema' of github.com:drizzle-team/…
AndriiSherman Jul 5, 2024
bd50c86
Updated:
ProvorovOleksii Jul 5, 2024
2929dff
Remove ava from all tests in project
AndriiSherman Jul 6, 2024
5933e0d
Merge branch 'fix-rqb-tables-with-schema' of github.com:drizzle-team/…
AndriiSherman Jul 6, 2024
1a896ea
Update all tests
AndriiSherman Jul 6, 2024
e6d3ae7
Fix test runs
AndriiSherman Jul 6, 2024
f0fa556
Fix mysql ports and skip xata-http for now
AndriiSherman Jul 6, 2024
9e324d0
skip 2 tests
AndriiSherman Jul 6, 2024
aa79b3f
Add 1 test
AndriiSherman Jul 6, 2024
ee089d9
Upgrade @arethetypeswrong/cli
AndriiSherman Jul 6, 2024
b59b8f5
Merge pull request #2363 from drizzle-team/fix-rqb-tables-with-schema
AndriiSherman Jul 8, 2024
a90773c
Update release 0.31.3
AndriiSherman Jul 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ examples
**/*.mjs
**/*.cjs
**/playground
integration-tests/tests/prisma/*/client
integration-tests/tests/prisma/*/drizzle
18 changes: 16 additions & 2 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ plugins:
- import
- unused-imports
- no-instanceof
- drizzle
- drizzle-internal
overrides:
- files:
- '**/tests/**/*.ts'
- '**/type-tests/**/*.ts'
rules:
import/extensions: 'off'
no-instanceof: 'off'
- files: 'eslint-plugin-drizzle/**/*'
rules:
import/extensions: 'off'
rules:
'@typescript-eslint/consistent-type-imports':
- error
Expand All @@ -24,6 +34,10 @@ rules:
import/no-useless-path-segments: error
import/newline-after-import: error
import/no-duplicates: error
import/extensions:
- error
- always
- ignorePackages: true
'@typescript-eslint/no-explicit-any': 'off'
'@typescript-eslint/no-non-null-assertion': 'off'
'@typescript-eslint/no-namespace': 'off'
Expand Down Expand Up @@ -61,7 +75,7 @@ rules:
'unicorn/relative-url-style': 'off'
'eqeqeq': 'error'
'no-instanceof/no-instanceof': 'error'
'drizzle/require-entity-kind': 'error'
'drizzle-internal/require-entity-kind': 'error'
'unicorn/prefer-string-replace-all': 'off'
'unicorn/no-process-exit': 'off'
'@typescript-eslint/ban-ts-comment': 'off'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
permissions:
actions: read
contents: read
Expand Down
20 changes: 15 additions & 5 deletions .github/workflows/release-feature-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
- 55432:5432
mysql:
image: mysql:8
env:
Expand All @@ -73,13 +73,13 @@ jobs:
--health-timeout 5s
--health-retries 5
ports:
- 3306:3306
- 33306:3306
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 18
node-version: '18.18'
registry-url: 'https://registry.npmjs.org'

- uses: pnpm/action-setup@v3
Expand Down Expand Up @@ -131,15 +131,25 @@ jobs:
- name: Build
if: steps.checks.outputs.has_new_release == 'true'
run: |
(
cd drizzle-orm
pnpm prisma generate --schema src/prisma/schema.prisma
)
(
cd integration-tests
pnpm prisma generate --schema tests/prisma/pg/schema.prisma
pnpm prisma generate --schema tests/prisma/mysql/schema.prisma
pnpm prisma generate --schema tests/prisma/sqlite/schema.prisma
)
pnpm build

- name: Run tests
if: steps.checks.outputs.has_new_release == 'true'
env:
PG_CONNECTION_STRING: postgres://postgres:postgres@localhost:5432/drizzle
PG_CONNECTION_STRING: postgres://postgres:postgres@localhost:55432/drizzle
PG_VECTOR_CONNECTION_STRING: postgres://postgres:postgres@localhost:54321/drizzle
PG_POSTGIS_CONNECTION_STRING: postgres://postgres:postgres@localhost:54322/drizzle
MYSQL_CONNECTION_STRING: mysql://root:root@localhost:3306/drizzle
MYSQL_CONNECTION_STRING: mysql://root:root@localhost:33306/drizzle
PLANETSCALE_CONNECTION_STRING: ${{ secrets.PLANETSCALE_CONNECTION_STRING }}
NEON_CONNECTION_STRING: ${{ secrets.NEON_CONNECTION_STRING }}
TIDB_CONNECTION_STRING: ${{ secrets.TIDB_CONNECTION_STRING }}
Expand Down
20 changes: 15 additions & 5 deletions .github/workflows/release-latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
- 55432:5432
mysql:
image: mysql:8
env:
Expand All @@ -66,13 +66,13 @@ jobs:
--health-timeout 5s
--health-retries 5
ports:
- 3306:3306
- 33306:3306
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 18
node-version: '18.18'
registry-url: 'https://registry.npmjs.org'

- uses: pnpm/action-setup@v3
Expand Down Expand Up @@ -134,15 +134,25 @@ jobs:
- name: Build
if: steps.checks.outputs.has_new_release == 'true'
run: |
(
cd drizzle-orm
pnpm prisma generate --schema src/prisma/schema.prisma
)
(
cd integration-tests
pnpm prisma generate --schema tests/prisma/pg/schema.prisma
pnpm prisma generate --schema tests/prisma/mysql/schema.prisma
pnpm prisma generate --schema tests/prisma/sqlite/schema.prisma
)
pnpm build

- name: Run tests
if: steps.checks.outputs.has_new_release == 'true'
env:
PG_CONNECTION_STRING: postgres://postgres:postgres@localhost:5432/drizzle
PG_CONNECTION_STRING: postgres://postgres:postgres@localhost:55432/drizzle
PG_VECTOR_CONNECTION_STRING: postgres://postgres:postgres@localhost:54321/drizzle
PG_POSTGIS_CONNECTION_STRING: postgres://postgres:postgres@localhost:54322/drizzle
MYSQL_CONNECTION_STRING: mysql://root:root@localhost:3306/drizzle
MYSQL_CONNECTION_STRING: mysql://root:root@localhost:33306/drizzle
PLANETSCALE_CONNECTION_STRING: ${{ secrets.PLANETSCALE_CONNECTION_STRING }}
NEON_CONNECTION_STRING: ${{ secrets.NEON_CONNECTION_STRING }}
TIDB_CONNECTION_STRING: ${{ secrets.TIDB_CONNECTION_STRING }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unpublish-release-feature-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: 18
node-version: '18.18'
registry-url: 'https://registry.npmjs.org'

- name: Unpublish
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ dist.new
.rollup.cache
dist-dts
rollup.config-*.mjs
*.log
.DS_Store
2 changes: 2 additions & 0 deletions changelogs/drizzle-orm/0.31.0-beta.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,5 @@ db.select({ innerProduct: sql`(${maxInnerProduct(items.embedding, [3,1,2])}) * -

// and more!
```

- 🛠️ Fixed RQB behavior for tables with same names in different schemas
17 changes: 17 additions & 0 deletions changelogs/drizzle-orm/0.31.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
### Bug fixed

- 🛠️ Fixed RQB behavior for tables with same names in different schemas
- 🛠️ Fixed [BUG]: Mismatched type hints when using RDS Data API - #2097

### New Prisma-Drizzle extension

```ts
import { PrismaClient } from '@prisma/client';
import { drizzle } from 'drizzle-orm/prisma/pg';
import { User } from './drizzle';

const prisma = new PrismaClient().$extends(drizzle());
const users = await prisma.$drizzle.select().from(User);
```

For more info, check docs: https://orm.drizzle.team/docs/prisma
10 changes: 6 additions & 4 deletions dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
"**/*snapshot.json",
"**/_journal.json",
"**/tsup.config*.mjs",
"**/.sst"
"**/.sst",
"integration-tests/tests/prisma/*/client",
"integration-tests/tests/prisma/*/drizzle"
],
"plugins": [
"https://plugins.dprint.dev/typescript-0.83.0.wasm",
"https://plugins.dprint.dev/json-0.19.2.wasm",
"https://plugins.dprint.dev/markdown-0.15.2.wasm"
"https://plugins.dprint.dev/typescript-0.91.1.wasm",
"https://plugins.dprint.dev/json-0.19.3.wasm",
"https://plugins.dprint.dev/markdown-0.17.1.wasm"
]
}
13 changes: 8 additions & 5 deletions drizzle-orm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "drizzle-orm",
"version": "0.31.2",
"version": "0.31.3",
"description": "Drizzle ORM package for SQL databases",
"type": "module",
"scripts": {
Expand Down Expand Up @@ -51,6 +51,8 @@
"@op-engineering/op-sqlite": ">=2",
"@opentelemetry/api": "^1.4.1",
"@planetscale/database": ">=1",
"@prisma/client": "*",
"@tidbcloud/serverless": "*",
"@types/better-sqlite3": "*",
"@types/pg": "*",
"@types/react": ">=18",
Expand All @@ -67,8 +69,7 @@
"postgres": ">=3",
"react": ">=18",
"sql.js": ">=1",
"sqlite3": ">=5",
"@tidbcloud/serverless": "*"
"sqlite3": ">=5"
},
"peerDependenciesMeta": {
"mysql2": {
Expand Down Expand Up @@ -160,6 +161,7 @@
"@opentelemetry/api": "^1.4.1",
"@originjs/vite-plugin-commonjs": "^1.0.3",
"@planetscale/database": "^1.16.0",
"@prisma/client": "5.14.0",
"@tidbcloud/serverless": "^0.1.1",
"@types/better-sqlite3": "^7.6.4",
"@types/node": "^20.2.5",
Expand All @@ -177,13 +179,14 @@
"mysql2": "^3.3.3",
"pg": "^8.11.0",
"postgres": "^3.3.5",
"prisma": "5.14.0",
"react": "^18.2.0",
"sql.js": "^1.8.0",
"sqlite3": "^5.1.2",
"tslib": "^2.5.2",
"tsx": "^3.12.7",
"vite-tsconfig-paths": "^4.2.0",
"vitest": "^0.31.4",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0",
"zod": "^3.20.2",
"zx": "^7.2.2"
}
Expand Down
8 changes: 4 additions & 4 deletions drizzle-orm/scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ await fs.remove('dist.new');

await Promise.all([
(async () => {
await $`tsup`;
await $`tsup`.stdio('pipe', 'pipe', 'pipe');
})(),
(async () => {
await $`tsc -p tsconfig.dts.json`;
await $`tsc -p tsconfig.dts.json`.stdio('pipe', 'pipe', 'pipe');
await cpy('dist-dts/**/*.d.ts', 'dist.new', {
rename: (basename) => basename.replace(/\.d\.ts$/, '.d.cts'),
});
Expand All @@ -64,8 +64,8 @@ await Promise.all([
]);

await Promise.all([
$`tsup src/version.ts --no-config --dts --format esm --outDir dist.new`,
$`tsup src/version.ts --no-config --dts --format cjs --outDir dist.new`,
$`tsup src/version.ts --no-config --dts --format esm --outDir dist.new`.stdio('pipe', 'pipe', 'pipe'),
$`tsup src/version.ts --no-config --dts --format cjs --outDir dist.new`.stdio('pipe', 'pipe', 'pipe'),
]);

await $`scripts/fix-imports.ts`;
Expand Down
11 changes: 3 additions & 8 deletions drizzle-orm/src/aws-data-api/pg/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,14 @@ export class AwsPgDialect extends PgDialect {
{ table, values, onConflict, returning }: PgInsertConfig<PgTable<TableConfig>>,
): SQL<unknown> {
const columns: Record<string, PgColumn> = table[Table.Symbol.Columns];
const colEntries: [string, PgColumn][] = Object.entries(columns);
for (const value of values) {
for (const [fieldName, col] of colEntries) {
for (const fieldName of Object.keys(columns)) {
const colValue = value[fieldName];
if (
is(colValue, Param) && colValue.value !== undefined && is(colValue.encoder, PgArray)
&& Array.isArray(colValue.value)
) {
value[fieldName] = sql`cast(${col.mapToDriverValue(colValue.value)} as ${
sql.raw(colValue.encoder.getSQLType())
})`;
value[fieldName] = sql`cast(${colValue} as ${sql.raw(colValue.encoder.getSQLType())})`;
}
}
}
Expand All @@ -83,9 +80,7 @@ export class AwsPgDialect extends PgDialect {
currentColumn && is(colValue, Param) && colValue.value !== undefined && is(colValue.encoder, PgArray)
&& Array.isArray(colValue.value)
) {
set[colName] = sql`cast(${currentColumn?.mapToDriverValue(colValue.value)} as ${
sql.raw(colValue.encoder.getSQLType())
})`;
set[colName] = sql`cast(${colValue} as ${sql.raw(colValue.encoder.getSQLType())})`;
}
}
return super.buildUpdateSet(table, set);
Expand Down
4 changes: 2 additions & 2 deletions drizzle-orm/src/aws-data-api/pg/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import type { Logger } from '~/logger.ts';
import {
type PgDialect,
PgPreparedQuery,
type PgQueryResultHKT,
PgSession,
PgTransaction,
type PgTransactionConfig,
type PreparedQueryConfig,
type QueryResultHKT,
} from '~/pg-core/index.ts';
import type { SelectedFieldsOrdered } from '~/pg-core/query-builders/select.types.ts';
import type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';
Expand Down Expand Up @@ -265,6 +265,6 @@ export class AwsDataApiTransaction<

export type AwsDataApiPgQueryResult<T> = ExecuteStatementCommandOutput & { rows: T[] };

export interface AwsDataApiPgQueryResultHKT extends QueryResultHKT {
export interface AwsDataApiPgQueryResultHKT extends PgQueryResultHKT {
type: AwsDataApiPgQueryResult<any>;
}
4 changes: 2 additions & 2 deletions drizzle-orm/src/d1/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function d1ToRawMapping(results: any) {
}

export class D1PreparedQuery<T extends PreparedQueryConfig = PreparedQueryConfig> extends SQLitePreparedQuery<
{ type: 'async'; run: D1Result; all: T['all']; get: T['get']; values: T['values']; execute: T['execute'] }
{ type: 'async'; run: D1Response; all: T['all']; get: T['get']; values: T['values']; execute: T['execute'] }
> {
static readonly [entityKind]: string = 'D1PreparedQuery';

Expand Down Expand Up @@ -177,7 +177,7 @@ export class D1PreparedQuery<T extends PreparedQueryConfig = PreparedQueryConfig
this.stmt = stmt;
}

run(placeholderValues?: Record<string, unknown>): Promise<D1Result> {
run(placeholderValues?: Record<string, unknown>): Promise<D1Response> {
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
this.logger.logQuery(this.query.sql, params);
return this.stmt.bind(...params).run();
Expand Down
Loading