From 4a5769749876fe2e551c23e8f370d536d4821f75 Mon Sep 17 00:00:00 2001 From: "Bruno O. Notario" Date: Fri, 8 Mar 2024 17:32:35 -0300 Subject: [PATCH] Use different InsertWriter for SQLite and Postgre --- system/MagiQL/Builder/Syntax/WriterFactory.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/system/MagiQL/Builder/Syntax/WriterFactory.php b/system/MagiQL/Builder/Syntax/WriterFactory.php index 3a16db5..600b51a 100644 --- a/system/MagiQL/Builder/Syntax/WriterFactory.php +++ b/system/MagiQL/Builder/Syntax/WriterFactory.php @@ -82,6 +82,23 @@ final class WriterFactory */ public static function createInsertWriter(\Phacil\Framework\MagiQL\Api\BuilderInterface $writer, PlaceholderWriter $placeholderWriter) { + /** @var \Phacil\Framework\MagiQL $writer */ + switch ($writer->getDb()->getDBTypeId()) { + case DatabaseDriverInterface::LIST_DB_TYPE_ID['MYSQL']: + case DatabaseDriverInterface::LIST_DB_TYPE_ID['MSSQL']: + case DatabaseDriverInterface::LIST_DB_TYPE_ID['ORACLE']: + return new InsertWriter($writer, $placeholderWriter); + break; + + case DatabaseDriverInterface::LIST_DB_TYPE_ID['POSTGRE']: + case DatabaseDriverInterface::LIST_DB_TYPE_ID['SQLLITE3']: + return new \Phacil\Framework\MagiQL\Builder\Syntax\Adapt\SQLite3\InsertWriter($writer, $placeholderWriter); + break; + + default: + return new InsertWriter($writer, $placeholderWriter); + break; + } return new InsertWriter($writer, $placeholderWriter); }