haxetink / tink_sql

SQL embedded into Haxe
MIT License
53 stars 17 forks source link

[Feature request] Add an option to ignore/remove `@:primary`/`@:autoIncrement` fields in `INSERT` queries #149

Open cedx opened 2 years ago

cedx commented 2 years ago

I query an SQL Server instance through a MariaDB server (more on this: #133).

When we call insertOne or insertMany methods, the generated SQL query use a NULL value for @:primary/@:autoIncrement fields (of course, if these fields are not filled in).

This is fine with MySQL/MariaDB: the server understands that we want to trigger the AUTO_INCREMENT behavior. But this fails with SQL Server which does not allow an autoincremented field (i.e. an IDENTITY one) to be specified in the SQL query.

It would be very handy if we had an option in insertOne and insertMany methods, or a dedicated metadata (@:ignoreOnInsert ? @:ignoreOnNull ?), to ignore/remove these fields in the generated SQL query.