This repository has been archived by the owner on Dec 12, 2023. It is now read-only.
fix(deps): update dependency drizzle-orm to ^0.29.0 #91
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
^0.28.5
->^0.29.0
Release Notes
drizzle-team/drizzle-orm (drizzle-orm)
v0.29.1
Compare Source
Fixes
New Features/Helpers
🎉 Detailed JSDoc for all query builders in all dialects - thanks @realmikesolo
You can now access more information, hints, documentation links, etc. while developing and using JSDoc right in your IDE. Previously, we had them only for filter expressions, but now you can see them for all parts of the Drizzle query builder
🎉 New helpers for aggregate functions in SQL - thanks @L-Mario564
Here is a list of functions and equivalent using
sql
templatecount
countDistinct
avg
avgDistinct
sum
sumDistinct
max
min
New Packages
🎉 ESLint Drizzle Plugin
For cases where it's impossible to perform type checks for specific scenarios, or where it's possible but error messages would be challenging to understand, we've decided to create an ESLint package with recommended rules. This package aims to assist developers in handling crucial scenarios during development
Install
You can install those packages for typescript support in your IDE
Usage
Create a
.eslintrc.yml
file, adddrizzle
to theplugins
, and specify the rules you want to use. You can find a list of all existing rules belowAll config
This plugin exports an
all
config that makes use of all rules (except for deprecated ones).At the moment,
all
is equivalent torecommended
Rules
enforce-delete-with-where: Enforce using
delete
with the.where()
clause in the.delete()
statement. Most of the time, you don't need to delete all rows in the table and require some kind ofWHERE
statements.Error Message:
Optionally, you can define a
drizzleObjectName
in the plugin options that accept astring
orstring[]
. This is useful when you have objects or classes with a delete method that's not from Drizzle. Such adelete
method will trigger the ESLint rule. To avoid that, you can define the name of the Drizzle object that you use in your codebase (like db) so that the rule would only trigger if the delete method comes from this object:Example, config 1:
Example, config 2:
enforce-update-with-where: Enforce using
update
with the.where()
clause in the.update()
statement. Most of the time, you don't need to update all rows in the table and require some kind ofWHERE
statements.Error Message:
Optionally, you can define a
drizzleObjectName
in the plugin options that accept astring
orstring[]
. This is useful when you have objects or classes with a delete method that's not from Drizzle. Such asupdate
method will trigger the ESLint rule. To avoid that, you can define the name of the Drizzle object that you use in your codebase (like db) so that the rule would only trigger if the delete method comes from this object:Example, config 1:
Example, config 2:
v0.29.0
Compare Source
New Features
🎉 MySQL
unsigned
option for bigintYou can now specify
bigint unsigned
typeRead more in docs
🎉 Improved query builder types
Starting from
0.29.0
by default, as all the query builders in Drizzle try to conform to SQL as much as possible, you can only invoke most of the methods once. For example, in a SELECT statement there might only be one WHERE clause, so you can only invoke .where() once:This behavior is useful for conventional query building, i.e. when you create the whole query at once. However, it becomes a problem when you want to build a query dynamically, i.e. if you have a shared function that takes a query builder and enhances it. To solve this problem, Drizzle provides a special 'dynamic' mode for query builders, which removes the restriction of invoking methods only once. To enable it, you need to call .$dynamic() on a query builder.
Let's see how it works by implementing a simple withPagination function that adds LIMIT and OFFSET clauses to a query based on the provided page number and an optional page size:
Note that the withPagination function is generic, which allows you to modify the result type of the query builder inside it, for example by adding a join:
Read more in docs
🎉 Possibility to specify name for primary keys and foreign keys
There is an issue when constraint names exceed the 64-character limit of the database. This causes the database engine to truncate the name, potentially leading to issues. Starting from
0.29.0
, you have the option to specify custom names for bothprimaryKey()
andforeignKey()
. We have also deprecated the oldprimaryKey()
syntax, which can still be used but will be removed in future releasesRead more in docs
🎉 Read Replicas Support
You can now use the Drizzle
withReplica
function to specify different database connections for read replicas and the main instance for write operations. By default,withReplicas
will use a random read replica for read operations and the main instance for all other data modification operations. You can also specify custom logic for choosing which read replica connection to use. You have the freedom to make any weighted, custom decision for that. Here are some usage examples:Implementation example of custom logic for selecting read replicas, where the first replica has a 70% chance of being chosen, and the second replica has a 30% chance of being chosen. Note that you can implement any type of random selection for read replicas
withReplicas
function is available for all dialects in Drizzle ORMRead more in docs
🎉 Set operators support (UNION, UNION ALL, INTERSECT, INTERSECT ALL, EXCEPT, EXCEPT ALL)
Huge thanks to @Angelelz for the significant contribution he made, from API discussions to proper type checks and runtime logic, along with an extensive set of tests. This greatly assisted us in delivering this feature in this release
Usage examples:
All set operators can be used in a two ways:
import approach
orbuilder approach
Import approach
Builder approach
Read more in docs
🎉 New MySQL Proxy Driver
A new driver has been released, allowing you to create your own implementation for an HTTP driver using a MySQL database. You can find usage examples in the
./examples/mysql-proxy
folderYou need to implement two endpoints on your server that will be used for queries and migrations(Migrate endpoint is optional and only if you want to use drizzle migrations). Both the server and driver implementation are up to you, so you are not restricted in any way. You can add custom mappings, logging, and much more
You can find both server and driver implementation examples in the
./examples/mysql-proxy
folder🎉 New PostgreSQL Proxy Driver
Same as MySQL you can now implement your own http driver for PostgreSQL database. You can find usage examples in the
./examples/pg-proxy
folderYou need to implement two endpoints on your server that will be used for queries and migrations (Migrate endpoint is optional and only if you want to use drizzle migrations). Both the server and driver implementation are up to you, so you are not restricted in any way. You can add custom mappings, logging, and much more
You can find both server and driver implementation examples in the
./examples/pg-proxy
folder🎉
D1
Batch API supportReference: https://developers.cloudflare.com/d1/platform/client-api/#dbbatch
Batch API usage example:
Type for
batchResponse
in this example would be:All possible builders that can be used inside
db.batch
:More usage examples here: integration-tests/tests/d1-batch.test.ts and in docs
Drizzle Kit 0.20.0
defineConfig
functionbigint unsigned
supportprimaryKeys
andforeignKeys
now can have custom namesYou can read more about drizzle-kit updates here
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.