Skip to content

Commit e360ef3

Browse files
authored
Merge pull request mysql2sqlite#48 from d-rep/master
handle varied letter casing of current_timestamp and optional parens
2 parents 3e05e81 + abf77da commit e360ef3

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

mysql2sqlite

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ aInc == 1 && /PRIMARY KEY|primary key/ { next }
183183
# BEGIN
184184
# UPDATE Package SET LastUpdate = CURRENT_TIMESTAMP WHERE ActionId = old.ActionId;
185185
# END
186-
gsub( /ON UPDATE CURRENT_TIMESTAMP|on update current_timestamp/, "" )
186+
gsub( /(ON|on) (UPDATE|update) (CURRENT_TIMESTAMP|current_timestamp)(\(\))?/, "" )
187+
gsub( /(DEFAULT|default) (CURRENT_TIMESTAMP|current_timestamp)(\(\))?/, "DEFAULT current_timestamp")
187188
gsub( /(COLLATE|collate) [^ ]+ /, "" )
188189
gsub( /(ENUM|enum)[^)]+\)/, "text " )
189190
gsub( /(SET|set)\([^)]+\)/, "text " )

unit_tests.sh

100644100755
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,25 @@ cat <<\SQL
101101
PARTITION p7 VALUES LESS THAN (2013) ENGINE = InnoDB)
102102
SQL
103103

104+
cat <<\SQLin
105+
CREATE TABLE `CCC`(
106+
`created` datetime DEFAULT current_timestamp(),
107+
`updated` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp()
108+
);
109+
SQLin
110+
111+
cat <<\SQLout
112+
PRAGMA synchronous = OFF;
113+
PRAGMA journal_mode = MEMORY;
114+
BEGIN TRANSACTION;
115+
CREATE TABLE `CCC`(
116+
`created` datetime DEFAULT current_timestamp
117+
, `updated` datetime DEFAULT current_timestamp
118+
);
119+
END TRANSACTION;
120+
SQLout
121+
122+
104123
cat <<\SQL
105124
SQL
125+

0 commit comments

Comments
 (0)