-
-
Notifications
You must be signed in to change notification settings - Fork 146
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
[Snyk] Upgrade drizzle-orm from 0.36.0 to 0.39.1 #1249
base: develop
Are you sure you want to change the base?
[Snyk] Upgrade drizzle-orm from 0.36.0 to 0.39.1 #1249
Conversation
Snyk has created this PR to upgrade drizzle-orm from 0.36.0 to 0.39.1. See this package in npm: drizzle-orm See this project in Snyk: https://app.snyk.io/org/nialljoemaher/project/8ac19f6c-c7f2-4720-acd1-09701979877c?utm_source=github&utm_medium=referral&page=upgrade-pr
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Important Review skippedIgnore keyword(s) in the title. ⛔ Ignored keywords (1)
Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Snyk has created this PR to upgrade drizzle-orm from 0.36.0 to 0.39.1.
ℹ️ Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.
The recommended version is 79 versions ahead of your current version.
The recommended version was released a month ago.
Release notes
Package name: drizzle-orm
aliasedTable()
New features
Bun SQL driver support
You can now use the new Bun SQL driver released in Bun v1.2.0 with Drizzle
const db = drizzle(process.env.PG_DB_URL!);
const result = await db.select().from(...);
or you can use Bun SQL instance
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
andjsonb
inserts and selects currently perform an additionalJSON.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
, andtimestamp
will not work properly when usingmode: 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.WITH now supports INSERT, UPDATE, DELETE and raw sql template
with
andinsert
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
andupdate
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
anddelete
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
andsql
id: serial('id').primaryKey(),
name: text('name').notNull(),
});
const sq = db.$with('sq', {
userId: users.id,
data: {
name: users.name,
},
}).as(sql
select * from <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">users</span><span class="pl-kos">}</span></span> where <span class="pl-s1"><span class="pl-kos">${</span><span class="pl-s1">users</span><span class="pl-kos">.</span><span class="pl-c1">name</span><span class="pl-kos">}</span></span> = 'John'
);const result = await db.with(sq).select().from(sq);
New tables in
/neon
importIn this release you can use
neon_identity
schema andusers_sync
table inside this schema by just importing it from/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 functionexport 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
vector
- thanks @ mitchwadairNew features
USE INDEX
,FORCE INDEX
andIGNORE INDEX
for MySQLIn MySQL, the statements USE INDEX, FORCE INDEX, and IGNORE INDEX are hints used in SQL queries to influence how the query optimizer selects indexes. These hints provide fine-grained control over index usage, helping optimize performance when the default behavior of the optimizer is not ideal.
Use Index
The
USE INDEX
hint suggests to the optimizer which indexes to consider when processing the query. The optimizer is not forced to use these indexes but will prioritize them if they are suitable.id: int('id').primaryKey(),
name: varchar('name', { length: 100 }).notNull(),
}, () => [usersTableNameIndex]);
const usersTableNameIndex = index('users_name_index').on(users.name);
await db.select()
.from(users, { useIndex: usersTableNameIndex })
.where(eq(users.name, 'David'));
Ignore Index
The
IGNORE INDEX
hint tells the optimizer to avoid using specific indexes for the query. MySQL will consider all other indexes (if any) or perform a full table scan if necessary.id: int('id').primaryKey(),
name: varchar('name', { length: 100 }).notNull(),
}, () => [usersTableNameIndex]);
const usersTableNameIndex = index('users_name_index').on(users.name);
await db.select()
.from(users, { ignoreIndex: usersTableNameIndex })
.where(eq(users.name, 'David'));
Force Index
The
FORCE INDEX
hint forces the optimizer to use the specified index(es) for the query. If the specified index cannot be used, MySQL will not fall back to other indexes; it might resort to a full table scan instead.id: int('id').primaryKey(),
name: varchar('name', { length: 100 }).notNull(),
}, () => [usersTableNameIndex]);
const usersTableNameIndex = index('users_name_index').on(users.name);
await db.select()
.from(users, { forceIndex: usersTableNameIndex })
.where(eq(users.name, 'David'));
You can also combine those hints and use multiple indexes in a query if you need
Important
Note: You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs.
For more information: