I have several tables like the example below. I use unsigned integers. Since unsigned is not recognized, I quote the datatype.
table tablename {
id "int unsigned" [pk, increment]
idOtherTable "int unsigned"
somedata varchar(32)
records (idOtherTable, someData) {
10, 'sample1'
20, 'sample2'
}
}
this leads to this MySQL definition:
CREATE TABLE `tablename` (
`id` int unsigned PRIMARY KEY AUTO_INCREMENT,
`idOtherTable` int unsigned,
`someData` varchar(32)
);
-- Disable foreign key checks for INSERT
SET FOREIGN_KEY_CHECKS = 0;
INSERT INTO `tablename` (`idOtherTable`, `someData`)
VALUES
(CAST('10' AS int unsigned), 'sample1'),
(CAST('20' AS int unsigned), 'sample2');
-- Re-enable foreign key checks
SET FOREIGN_KEY_CHECKS = 1;
But running this results in:
#1064 - 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 ‘unsigned), ‘sample1’),
(CAST(‘20’ AS int unsigned), ‘sample2’)’ at line 3
And here’s the problem: for a column definition the notation is int unsigned but for a cast it’s unsigned int
I know this is actually a MySQL problem, but could you add “unsigned” as a recognizable word ? (so the cast will disappear)