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 #3989

Merged
merged 55 commits into from
Jan 26, 2025
Merged

Beta #3989

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
016000a
Implement type coercion in drizzle-zod
L-Mario564 Dec 26, 2024
6201629
Add shorthand syntax to coerce option
L-Mario564 Dec 26, 2024
dc5fa3d
bugfix: Fix a bug that caused output without specifying index name
Karibash Aug 1, 2024
6b06a03
Fixed vercel session's lack of `count` override (fixes #3710)
Sukairo-02 Jan 9, 2025
abce48e
Simplify JSON column definitions
L-Mario564 Jan 13, 2025
7a8a7c6
Export `BuildSchema` internal type in validator packages
L-Mario564 Jan 13, 2025
e8a5559
Added getViewName
carloschida Jan 14, 2025
5d836f1
feat: singlestore recreate
AleksandrSherman Jan 14, 2025
055ab2c
Merge branch 'beta' of https://github.com/drizzle-team/drizzle-orm in…
AleksandrSherman Jan 14, 2025
2eba335
Add $count function to withReplica client in all dialects
AndrewJo Jan 14, 2025
638b6ab
Test $count withReplicas
AndrewJo Jan 14, 2025
0a0cdd2
updated tests
AleksandrSherman Jan 15, 2025
af2ed2c
Add neon_identity integration
pffigueiredo Jan 16, 2025
3263fe5
Add insert and update as valid CTEs in PG
L-Mario564 Jan 16, 2025
b82c89e
Commit uncommited change
L-Mario564 Jan 17, 2025
67f3c1a
Add delete as a valid CTE in PG
L-Mario564 Jan 17, 2025
25882a4
Add insert, update and delete as CTE tests and fixes for PG
L-Mario564 Jan 17, 2025
000e49a
Update column.types.ts
Tiedye Jan 13, 2025
5f80c70
Add SQL operator as valid CTE in PG
L-Mario564 Jan 20, 2025
3e66ced
Add SQL operator as valid CTE for SQLite, MySQL and SS
L-Mario564 Jan 20, 2025
cec185c
Format
L-Mario564 Jan 20, 2025
0e583b0
Merge remote-tracking branch 'upstream/beta' into export-internals
L-Mario564 Jan 22, 2025
9637926
Merge remote-tracking branch 'upstream/beta' into better-ctes-2
L-Mario564 Jan 22, 2025
366b249
Fix PG tests
L-Mario564 Jan 22, 2025
201a63c
Format
L-Mario564 Jan 22, 2025
69862e4
Fix tests
L-Mario564 Jan 22, 2025
3e85dac
Attempt to fix type issues
L-Mario564 Jan 22, 2025
42f4a61
Merge pull request #3976 from L-Mario564/better-ctes-2
AndriiSherman Jan 23, 2025
40355d8
Merge branch 'beta' into 3959-setup-neon_identity
AndriiSherman Jan 23, 2025
eec8c31
Merge pull request #3960 from pffigueiredo/3959-setup-neon_identity
AndriiSherman Jan 23, 2025
9b81022
Merge branch 'beta' into fix-withreplica-$count
AndriiSherman Jan 23, 2025
6eac087
Merge pull request #3952 from AndrewJo/fix-withreplica-$count
AndriiSherman Jan 23, 2025
143e2bf
Merge branch 'beta' into drizzle-kit/singlestore-recreate
AndriiSherman Jan 23, 2025
14a676e
Merge branch 'beta' into main
AndriiSherman Jan 23, 2025
85db5ba
Merge pull request #3947 from carloschida/main
AndriiSherman Jan 23, 2025
e5b95a1
Merge branch 'beta' into patch-1
AndriiSherman Jan 23, 2025
e4cb269
Merge pull request #3939 from Tiedye/patch-1
AndriiSherman Jan 23, 2025
79df8c1
Merge pull request #3919 from drizzle-team/vercel-count-fix
AndriiSherman Jan 23, 2025
6ebfff4
update: returned validated instead of squashed for `filterStatements`…
AleksandrSherman Jan 23, 2025
6bdb5f7
Merge branch 'drizzle-kit/singlestore-recreate' of https://github.com…
AleksandrSherman Jan 23, 2025
4e4ee20
Merge branch 'beta' of https://github.com/drizzle-team/drizzle-orm in…
AleksandrSherman Jan 23, 2025
88fe396
fixed: drizzle-zod errors and dprint errors
AleksandrSherman Jan 23, 2025
3dff816
Merge pull request #3852 from L-Mario564/zod-coerce
AndriiSherman Jan 23, 2025
0e56bba
Merge branch 'beta' into export-internals
AndriiSherman Jan 23, 2025
0cd20b6
Merge pull request #3944 from L-Mario564/export-internals
AndriiSherman Jan 23, 2025
90cced1
Merge branch 'beta' into drizzle-kit/singlestore-recreate
AndriiSherman Jan 23, 2025
f9c666c
Merge pull request #3950 from drizzle-team/drizzle-kit/singlestore-re…
AndriiSherman Jan 23, 2025
b776df4
Bring ps tests back
AndriiSherman Jan 23, 2025
84987cd
Add bun sql driver
AndriiSherman Jan 24, 2025
9773c34
Add singlestore fix
AndriiSherman Jan 24, 2025
0babb04
Merge branch 'beta' into bugfix/index-name
AndriiSherman Jan 25, 2025
efae52b
Merge pull request #2733 from Karibash/bugfix/index-name
AndriiSherman Jan 25, 2025
0f1d891
Up versions and add release notes
AndriiSherman Jan 25, 2025
aa1668f
Merge branch 'beta' of github.com:drizzle-team/drizzle-orm into beta
AndriiSherman Jan 25, 2025
f36e3ea
remove .only
AndriiSherman Jan 25, 2025
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
7 changes: 7 additions & 0 deletions changelogs/drizzle-kit/0.30.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SingleStore `push` and `generate` improvements

As SingleStore did not support certain DDL statements before this release, you might encounter an error indicating that some schema changes cannot be applied due to a database issue. Starting from this version, drizzle-kit will detect such cases and initiate table recreation with data transfer between the tables

# Bug fixes

- [[BUG] If the index name is the same as the generated name, it will be empty and a type error will occur](https://github.com/drizzle-team/drizzle-orm/issues/3420)
154 changes: 154 additions & 0 deletions changelogs/drizzle-orm/0.39.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# New features

## Bun SQL driver support
You can now use the new Bun SQL driver released in Bun v1.2.0 with Drizzle

```ts
import { drizzle } from 'drizzle-orm/bun-sql';

const db = drizzle(process.env.PG_DB_URL!);

const result = await db.select().from(...);
```

or you can use Bun SQL instance

```ts
import { drizzle } from 'drizzle-orm/bun-sqlite';
import { SQL } from 'bun';

const client = new SQL(process.env.PG_DB_URL!);
const db = drizzle({ client });

const result = await db.select().from(...);
```

Current Limitations:

- `json` and `jsonb` inserts and selects currently perform an additional `JSON.stringify` on the Bun SQL side. Once this is removed, they should work properly. You can always use custom types and redefine the mappers to and from the database.
- `datetime`, `date`, and `timestamp` will not work properly when using `mode: string` in Drizzle. This is due to Bun's API limitations, which prevent custom parsers for queries. As a result, Drizzle cannot control the response sent from Bun SQL to Drizzle. Once this feature is added to Bun SQL, it should work as expected.
- `array` types currently have issues in Bun SQL.

> You can check more in [Bun docs](https://bun.sh/docs/api/sql)
>
> You can check more getting started examples in [Drizzle docs](https://orm.drizzle.team/docs/get-started/bun-sql-new)

## WITH now supports INSERT, UPDATE, DELETE and raw sql template

**`with` and `insert`**

```ts
const users = pgTable('users', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
});

const sq = db.$with('sq').as(
db.insert(users).values({ name: 'John' }).returning(),
);

const result = await db.with(sq).select().from(sq);
```

**`with` and `update`**

```ts
const users = pgTable('users', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
});

const sq = db.$with('sq').as(
db.update(users).set({ age: 25 }).where(eq(users.name, 'John')).returning(),
);
const result = await db.with(sq).select().from(sq);
```

**`with` and `delete`**

```ts
const users = pgTable('users', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
});

const sq = db.$with('sq').as(
db.delete(users).where(eq(users.name, 'John')).returning(),
);

const result = await db.with(sq).select().from(sq);
```

**`with` and `sql`**

```ts
const users = pgTable('users', {
id: serial('id').primaryKey(),
name: text('name').notNull(),
});

const sq = db.$with('sq', {
userId: users.id,
data: {
name: users.name,
},
}).as(sql`select * from ${users} where ${users.name} = 'John'`);

const result = await db.with(sq).select().from(sq);
```

## New tables in `/neon` import

In this release you can use `neon_identity` schema and `users_sync` table inside this schema by just importing it from `/neon`

```ts
// "drizzle-orm/neon"
const neonIdentitySchema = pgSchema('neon_identity');

/**
* Table schema of the `users_sync` table used by Neon Identity.
* This table automatically synchronizes and stores user data from external authentication providers.
*
* @schema neon_identity
* @table users_sync
*/
export const usersSync = neonIdentitySchema.table('users_sync', {
rawJson: jsonb('raw_json').notNull(),
id: text().primaryKey().notNull(),
name: text(),
email: text(),
createdAt: timestamp('created_at', { withTimezone: true, mode: 'string' }),
deletedAt: timestamp('deleted_at', { withTimezone: true, mode: 'string' }),
});
```

# Utils and small improvements

## `getViewName` util function

```ts
import { getViewName } from 'drizzle-orm/sql'

export const user = pgTable("user", {
id: serial(),
name: text(),
email: text(),
});

export const userView = pgView("user_view").as((qb) => qb.select().from(user));

const viewName = getViewName(userView)
```

# Bug fixed and GitHub issue closed

- [[FEATURE]: allow INSERT in CTEs (WITH clauses)](https://github.com/drizzle-team/drizzle-orm/issues/2078)
- [[FEATURE]: Support Raw SQL in CTE Query Builder](https://github.com/drizzle-team/drizzle-orm/issues/2168)
- [[FEATURE]: include pre-defined database objects related to Neon Identity in drizzle-orm](https://github.com/drizzle-team/drizzle-orm/issues/3959)
- [[BUG]: $count is undefined on withReplicas](https://github.com/drizzle-team/drizzle-orm/issues/3951)
- [[FEATURE]: get[Materialized]ViewName, ie getTableName but for (materialized) views.](https://github.com/drizzle-team/drizzle-orm/issues/3946)
- [[BUG]: $count API error with vercel-postgres](https://github.com/drizzle-team/drizzle-orm/issues/3710)
- [[BUG]: Cannot use schema.coerce on refining drizzle-zod types](https://github.com/drizzle-team/drizzle-orm/issues/3842)
- [[FEATURE]: Type Coercion in drizzle-zod](https://github.com/drizzle-team/drizzle-orm/issues/776)
- [[BUG]: The inferred type of X cannot be named without a reference to ../../../../../node_modules/drizzle-zod/schema.types.internal.mjs](https://github.com/drizzle-team/drizzle-orm/issues/3732)
- [[BUG]: drizzle-zod excessively deep and possibly infinite types](https://github.com/drizzle-team/drizzle-orm/issues/3869)
4 changes: 4 additions & 0 deletions changelogs/drizzle-typebox/0.3.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Bug fixed and GitHub issue closed

- [[BUG]: The inferred type of X cannot be named without a reference to ../../../../../node_modules/drizzle-zod/schema.types.internal.mjs](https://github.com/drizzle-team/drizzle-orm/issues/3732)
- [[BUG]: drizzle-zod excessively deep and possibly infinite types](https://github.com/drizzle-team/drizzle-orm/issues/3869)
4 changes: 4 additions & 0 deletions changelogs/drizzle-valibot/0.4.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Bug fixed and GitHub issue closed

- [[BUG]: The inferred type of X cannot be named without a reference to ../../../../../node_modules/drizzle-zod/schema.types.internal.mjs](https://github.com/drizzle-team/drizzle-orm/issues/3732)
- [[BUG]: drizzle-zod excessively deep and possibly infinite types](https://github.com/drizzle-team/drizzle-orm/issues/3869)
37 changes: 37 additions & 0 deletions changelogs/drizzle-zod/0.7.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Improvements

## Added type coercion support

**Use case: Type coercion**

```ts copy
import { pgTable, timestamp } from 'drizzle-orm/pg-core';
import { createSchemaFactory } from 'drizzle-zod';
import { z } from 'zod';

const users = pgTable('users', {
...,
createdAt: timestamp().notNull()
});

const { createInsertSchema } = createSchemaFactory({
// This configuration will only coerce dates. Set `coerce` to `true` to coerce all data types or specify others
coerce: {
date: true
}
});

const userInsertSchema = createInsertSchema(users);
// The above is the same as this:
const userInsertSchema = z.object({
...,
createdAt: z.coerce.date()
});
```

# Bug fixed and GitHub issue closed

- [[BUG]: Cannot use schema.coerce on refining drizzle-zod types](https://github.com/drizzle-team/drizzle-orm/issues/3842)
- [[FEATURE]: Type Coercion in drizzle-zod](https://github.com/drizzle-team/drizzle-orm/issues/776)
- [[BUG]: The inferred type of X cannot be named without a reference to ../../../../../node_modules/drizzle-zod/schema.types.internal.mjs](https://github.com/drizzle-team/drizzle-orm/issues/3732)
- [[BUG]: drizzle-zod excessively deep and possibly infinite types](https://github.com/drizzle-team/drizzle-orm/issues/3869)
2 changes: 1 addition & 1 deletion drizzle-kit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "drizzle-kit",
"version": "0.30.2",
"version": "0.30.3",
"homepage": "https://orm.drizzle.team",
"keywords": [
"drizzle",
Expand Down
1 change: 1 addition & 0 deletions drizzle-kit/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ export const pushSingleStoreSchema = async (
db,
statements,
validatedCur,
validatedPrev,
);

return {
Expand Down
27 changes: 3 additions & 24 deletions drizzle-kit/src/cli/commands/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,34 +208,16 @@ export const singlestorePush = async (
db,
filteredStatements,
statements.validatedCur,
statements.validatedPrev,
);

const filteredSqlStatements = fromJson(filteredStatements, 'singlestore');

const uniqueSqlStatementsToExecute: string[] = [];
statementsToExecute.forEach((ss) => {
if (!uniqueSqlStatementsToExecute.includes(ss)) {
uniqueSqlStatementsToExecute.push(ss);
}
});
const uniqueFilteredSqlStatements: string[] = [];
filteredSqlStatements.forEach((ss) => {
if (!uniqueFilteredSqlStatements.includes(ss)) {
uniqueFilteredSqlStatements.push(ss);
}
});

if (verbose) {
console.log();
console.log(
withStyle.warning('You are about to execute current statements:'),
);
console.log();
console.log(
[...uniqueSqlStatementsToExecute, ...uniqueFilteredSqlStatements]
.map((s) => chalk.blue(s))
.join('\n'),
);
console.log(statementsToExecute.map((s) => chalk.blue(s)).join('\n'));
console.log();
}

Expand Down Expand Up @@ -289,13 +271,10 @@ export const singlestorePush = async (
}
}

for (const dStmnt of uniqueSqlStatementsToExecute) {
for (const dStmnt of statementsToExecute) {
await db.query(dStmnt);
}

for (const statement of uniqueFilteredSqlStatements) {
await db.query(statement);
}
if (filteredStatements.length > 0) {
render(`[${chalk.green('✓')}] Changes applied`);
} else {
Expand Down
Loading