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

fix(deps): update dependency drizzle-orm to v0.30.9 #16

Merged
merged 1 commit into from
May 1, 2024

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Apr 30, 2024

Mend Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
drizzle-orm (source) 0.29.4 -> 0.30.9 age adoption passing confidence

Release Notes

drizzle-team/drizzle-orm (drizzle-orm)

v0.30.9

Compare Source

  • 🐛 Fixed migrator in AWS Data API
  • Added setWhere and targetWhere fields to .onConflictDoUpdate() config in SQLite instead of single where field
  • 🛠️ Added schema information to Drizzle instances via db._.fullSchema

v0.30.8

Compare Source

  • 🎉 Added custom schema support to enums in Postgres (fixes #​669 via #​2048):

⚠️ Only available in drizzle-orm for now, drizzle-kit support will arrive soon

import { pgSchema } from 'drizzle-orm/pg-core';

const mySchema = pgSchema('mySchema');
const colors = mySchema.enum('colors', ['red', 'green', 'blue']);
  • 🎉 Changed D1 migrate() function to use batch API (#​2137)
  • 🐛 Split where clause in Postgres .onConflictDoUpdate method into setWhere and targetWhere clauses, to support both where cases in on conflict ... clause (fixes #​1628, #​1302 via #​2056)
  • 🐛 Fixed query generation for where clause in Postgres .onConflictDoNothing method, as it was placed in a wrong spot (fixes #​1628 via #​2056)
  • 🐛 Fixed multiple issues with AWS Data API driver (fixes #​1931, #​1932, #​1934, #​1936 via #​2119)
  • 🐛 Fix inserting and updating array values in AWS Data API (fixes #​1912 via #​1911)

Thanks @​hugo082 and @​livingforjesus!

v0.30.7

Compare Source

Bug fixes
  • Add mappings for @vercel/postgres package
  • Fix interval mapping for neon drivers - #​1542

v0.30.6

Compare Source

New Features

🎉 PGlite driver Support

PGlite is a WASM Postgres build packaged into a TypeScript client library that enables you to run Postgres in the browser, Node.js and Bun, with no need to install any other dependencies. It is only 2.6mb gzipped.

It can be used as an ephemeral in-memory database, or with persistence either to the file system (Node/Bun) or indexedDB (Browser).

Unlike previous "Postgres in the browser" projects, PGlite does not use a Linux virtual machine - it is simply Postgres in WASM.

Usage Example

import { PGlite } from '@​electric-sql/pglite';
import { drizzle } from 'drizzle-orm/pglite';

// In-memory Postgres
const client = new PGlite();
const db = drizzle(client);

await db.select().from(users);

There are currently 2 limitations, that should be fixed on Pglite side:

v0.30.5

Compare Source

New Features

🎉 $onUpdate functionality for PostgreSQL, MySQL and SQLite

Adds a dynamic update value to the column.
The function will be called when the row is updated, and the returned value will be used as the column value if none is provided.
If no default (or $defaultFn) value is provided, the function will be called when the row is inserted as well, and the returned value will be used as the column value.

Note: This value does not affect the drizzle-kit behavior, it is only used at runtime in drizzle-orm.

const usersOnUpdate = pgTable('users_on_update', {
  id: serial('id').primaryKey(),
  name: text('name').notNull(),
  updateCounter: integer('update_counter').default(sql`1`).$onUpdateFn(() => sql`update_counter + 1`),
  updatedAt: timestamp('updated_at', { mode: 'date', precision: 3 }).$onUpdate(() => new Date()),
  alwaysNull: text('always_null').$type<string | null>().$onUpdate(() => null),
});

Fixes

  • [BUG]: insertions on columns with the smallserial datatype are not optional - #​1848

Thanks @​Angelelz and @​gabrielDonnantuoni!

v0.30.4

Compare Source

New Features

🎉 xata-http driver support

According their official website, Xata is a Postgres data platform with a focus on reliability, scalability, and developer experience. The Xata Postgres service is currently in beta, please see the Xata docs on how to enable it in your account.

Drizzle ORM natively supports both the xata driver with drizzle-orm/xata package and the postgres or pg drivers for accessing a Xata Postgres database.

The following example use the Xata generated client, which you obtain by running the xata init CLI command.

pnpm add drizzle-orm @&#8203;xata.io/client
import { drizzle } from 'drizzle-orm/xata-http';
import { getXataClient } from './xata'; // Generated client

const xata = getXataClient();
const db = drizzle(xata);

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

You can also connect to Xata using pg or postgres.js drivers

v0.30.3

Compare Source

v0.30.2

Compare Source

Improvements

LibSQL migrations have been updated to utilize batch execution instead of transactions. As stated in the documentation, LibSQL now supports batch operations

A batch consists of multiple SQL statements executed sequentially within an implicit transaction. The backend handles the transaction: success commits all changes, while any failure results in a full rollback with no modifications.

Bug fixed

v0.30.1

Compare Source

New Features

🎉 OP-SQLite driver Support

Usage Example

import { open } from '@&#8203;op-engineering/op-sqlite';
import { drizzle } from 'drizzle-orm/op-sqlite';

const opsqlite = open({
	name: 'myDB',
});
const db = drizzle(opsqlite);

await db.select().from(users);

For more usage and setup details, please check our op-sqlite docs

Bug fixes
  • Migration hook fixed for Expo driver

v0.30.0

Compare Source

Breaking Changes

The Postgres timestamp mapping has been changed to align all drivers with the same behavior.

❗ We've modified the postgres.js driver instance to always return strings for dates, and then Drizzle will provide you with either strings of mapped dates, depending on the selected mode. The only issue you may encounter is that once you provide the `postgres.js`` driver instance inside Drizzle, the behavior of this object will change for dates, which will always be strings.

We've made this change as a minor release, just as a warning, that:

  • If you were using timestamps and were waiting for a specific response, the behavior will now be changed.
    When mapping to the driver, we will always use .toISOString for both timestamps with timezone and without timezone.

  • If you were using the postgres.js driver outside of Drizzle, all postgres.js clients passed to Drizzle will have mutated behavior for dates. All dates will be strings in the response.

Parsers that were changed for postgres.js.

const transparentParser = (val: any) => val;

// Override postgres.js default date parsers: https://github.com/porsager/postgres/discussions/761
for (const type of ['1184', '1082', '1083', '1114']) {
	client.options.parsers[type as any] = transparentParser;
	client.options.serializers[type as any] = transparentParser;
}

Ideally, as is the case with almost all other drivers, we should have the possibility to mutate mappings on a per-query basis, which means that the driver client won't be mutated. We will be reaching out to the creator of the postgres.js library to inquire about the possibility of specifying per-query mapping interceptors and making this flow even better for all users.

If we've overlooked this capability and it is already available with `postgres.js``, please ping us in our Discord!

A few more references for timestamps without and with timezones can be found in our docs

Bug fixed in this release

Big thanks to @​Angelelz!

  • [BUG]: timestamp with mode string is returned as Date object instead of string - #​806
  • [BUG]: Dates are always dates #​971
  • [BUG]: Inconsistencies when working with timestamps and corresponding datetime objects in javascript. #​1176
  • [BUG]: timestamp columns showing string type, however actually returning a Date object. #​1185
  • [BUG]: Wrong data type for postgres date colum #​1407
  • [BUG]: invalid timestamp conversion when using PostgreSQL with TimeZone set to UTC #​1587
  • [BUG]: Postgres insert into timestamp with time zone removes milliseconds #​1061
  • [BUG]: update timestamp field (using AWS Data API) #​1164
  • [BUG]: Invalid date from relational queries #​895

v0.29.5

Compare Source

New Features

🎉 WITH UPDATE, WITH DELETE, WITH INSERT - thanks @​L-Mario564

You can now use WITH statements with INSERT, UPDATE and DELETE statements

Usage examples

const averageAmount = db.$with('average_amount').as(
	db.select({ value: sql`avg(${orders.amount})`.as('value') }).from(orders),
);
const result = await db
	.with(averageAmount)
	.delete(orders)
	.where(gt(orders.amount, sql`(select * from ${averageAmount})`))
	.returning({
		id: orders.id,
	});

Generated SQL:

with "average_amount" as (select avg("amount") as "value" from "orders") 
delete from "orders" 
where "orders"."amount" > (select * from "average_amount") 
returning "id"

For more examples for all statements, check docs:

🎉 Possibility to specify custom schema and custom name for migrations table - thanks @​g3r4n
  • Custom table for migrations

By default, all information about executed migrations will be stored in the database inside the __drizzle_migrations table,
and for PostgreSQL, inside the drizzle schema. However, you can configure where to store those records.

To add a custom table name for migrations stored inside your database, you should use the migrationsTable option

Usage example

await migrate(db, {
	migrationsFolder: './drizzle',
	migrationsTable: 'my_migrations',
});
  • Custom schema for migrations

Works only with PostgreSQL databases

To add a custom schema name for migrations stored inside your database, you should use the migrationsSchema option

Usage example

await migrate(db, {
	migrationsFolder: './drizzle',
	migrationsSchema: 'custom',
});
🎉 SQLite Proxy bacth and Relational Queries support
  • You can now use .query.findFirst and .query.findMany syntax with sqlite proxy driver

  • SQLite Proxy supports batch requests, the same as it's done for all other drivers. Check full docs

    You will need to specify a specific callback for batch queries and handle requests to proxy server:

import { drizzle } from 'drizzle-orm/sqlite-proxy';

type ResponseType = { rows: any[][] | any[] }[];

const db = drizzle(
	async (sql, params, method) => {
		// single query logic
	},
	// new batch callback
	async (
		queries: {
			sql: string;
			params: any[];
			method: 'all' | 'run' | 'get' | 'values';
		}[],
	) => {
		try {
			const result: ResponseType = await axios.post(
				'http://localhost:3000/batch',
				{ queries },
			);

			return result;
		} catch (e: any) {
			console.error('Error from sqlite proxy server:', e);
			throw e;
		}
	},
);

And then you can use db.batch([]) method, that will proxy all queries

Response from the batch should be an array of raw values (an array within an array), in the same order as they were sent to the proxy server


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.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by Mend Renovate. View repository job log here.

@renovate renovate bot requested a review from cungminh2710 as a code owner April 30, 2024 13:52
Copy link

cloudflare-workers-and-pages bot commented Apr 30, 2024

Deploying coderum with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5971b52
Status: ✅  Deploy successful!
Preview URL: https://5789a862.coderum.pages.dev
Branch Preview URL: https://renovate-drizzle-orm-0-x.coderum.pages.dev

View logs

@renovate renovate bot force-pushed the renovate/drizzle-orm-0.x branch 4 times, most recently from 0331b37 to d1f43dd Compare April 30, 2024 23:54
@renovate renovate bot force-pushed the renovate/drizzle-orm-0.x branch from d1f43dd to 4fdf128 Compare April 30, 2024 23:59
@cungminh2710 cungminh2710 enabled auto-merge (squash) May 1, 2024 03:38
@cungminh2710 cungminh2710 merged commit 924b8d0 into main May 1, 2024
5 checks passed
@cungminh2710 cungminh2710 deleted the renovate/drizzle-orm-0.x branch May 1, 2024 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant