-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
Some SQL statements are not yet implemented (cf. DISTINCT), and others will probably never be implemented (i.e. SET foreign_key_checks = 0 or ALTER TABLE my_table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci on MySQL).
So we need a way to execute raw SQL queries to be able to escape from TinkSQL, that is probably expose the ident, run and value methods from the underlying driver.
Currently, I use this kind of horror (with Node.js and MySQL):
import tink.sql.Database;
import tink.sql.DatabaseDefinition;
import tink.sql.drivers.node.MySql.MySqlConnection;
import tink.sql.drivers.node.MySql.MySqlConnectionPool;
class Schema extends Database<SchemaTables> {
var connection(get, never): MySqlConnection<SchemaTables>;
function get_connection() {
final cnx: MySqlConnectionPool<SchemaTables> = cast @:privateAccess __cnx;
return new MySqlConnection(@:privateAccess cnx.info, @:privateAccess cnx.getNativeConnection(), true);
}
public inline function ident(identifier: String) return connection.ident(identifier);
public inline function run(statement: String) return @:privateAccess connection.run({sql: statement});
public inline function value(value: Any) return connection.value(value);
}
interface SchemaTables extends DatabaseDefinition {
@:table("table1") final table1: MyTableData1;
@:table("table2") final table2: MyTableData2;
}
serjek, sh-dave and tschikhof-io
Metadata
Metadata
Assignees
Labels
No labels