deepkit / deepkit-framework

A new full-featured and high-performance TypeScript framework
https://deepkit.io/
MIT License
3.2k stars 123 forks source link

OnDelete one or many records the orm shows mariadb syntax error #155

Closed Paula2001 closed 2 years ago

Paula2001 commented 2 years ago

Hey I am using your ORM for about 4 days now really a piece of art but unfortunately I have pumped into this error so is it a bug or I am missing something.

(conn=48, no: 1064, SQLState: 42000) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'DELETE `events` FROM `events` INNER JOIN _ INNER JOIN (SELECT...' at line 2 sql: WITH _ AS (SELECT `id` FROM `events` WHERE `events`.`id` = ? LIMIT 1) DELETE `events` FROM `events` INNER JOIN _ INNER JOIN (SELECT @_pk := JSON_ARRAYAGG(`id`) FROM _ GROUP BY '0') as _pk WHE...

when I try to delete one or many the engine shows this error :

this is my query const result = await EventEntity.query() .filter({ id: 5 }) .deleteOne();

// Removed some keys but config is good on my end this is my config { mariaDb: true, host:, port: , user: , database:, password:, connectionLimit:4 , acquireTimeout: 500 }

marcj commented 2 years ago

Which MariaDB are you using? The ORM is compatible to MySQL 8+, not 5.

Paula2001 commented 2 years ago

first thing first, you are amazing thanks for the fast reply <3 ,

This is my version 10.6.4-MariaDB-1:10.6.4

marcj commented 2 years ago

No problem! We have no MariaDB support yet, and it seems CTE with DELETE (which we use to simulate returning in MySQL) is not supported in MariaDB: https://jira.mariadb.org/browse/MDEV-18511. However, MariaDB supports DELETE with RETURNING, so we could create a new MariaDBAdapter and make it compatible. Tracked here https://github.com/deepkit/deepkit-framework/projects/1#card-70956508

Paula2001 commented 2 years ago

Merci <3 , I will track it also I was able to delete one row using ActiveRecord so yea thanks