You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
INSERT INTO `T_upsert` (`email`, `status`) SELECT `email`, 2 AS `status` FROM `customer` WHERE `name`=:qp0 LIMIT 1 ON DUPLICATE KEY UPDATE `status`=VALUES(`status`)
128
-
SQL,
122
+
3 => 'INSERT INTO `T_upsert` (`email`, `status`) SELECT `email`, 2 AS `status` FROM `customer` ' .
123
+
'WHERE `name`=:qp0 LIMIT 1 ON DUPLICATE KEY UPDATE `status`=VALUES(`status`)',
129
124
],
130
125
'query with update part' => [
131
-
3 => <<<SQL
132
-
INSERT INTO `T_upsert` (`email`, `status`) SELECT `email`, 2 AS `status` FROM `customer` WHERE `name`=:qp0 LIMIT 1 ON DUPLICATE KEY UPDATE `address`=:qp1, `status`=:qp2, `orders`=T_upsert.orders + 1
133
-
SQL,
126
+
3 => 'INSERT INTO `T_upsert` (`email`, `status`) SELECT `email`, 2 AS `status` FROM `customer` ' .
INSERT INTO `T_upsert` (`email`, `status`) SELECT `email`, 2 AS `status` FROM `customer` WHERE `name`=:qp0 LIMIT 1 ON DUPLICATE KEY UPDATE `email`=`T_upsert`.`email`
138
-
SQL,
130
+
3 => 'INSERT IGNORE INTO `T_upsert` (`email`, `status`) SELECT `email`, 2 AS `status` FROM `customer` ' .
131
+
'WHERE `name`=:qp0 LIMIT 1',
139
132
],
140
133
'values and expressions' => [
141
-
3 => <<<SQL
142
-
INSERT INTO {{%T_upsert}} ({{%T_upsert}}.[[email]], [[ts]]) VALUES (:qp0, now())
'query, values and expressions with update part' => [
156
-
3 => <<<SQL
157
-
INSERT INTO {{%T_upsert}} (`email`, [[time]]) SELECT :phEmail AS `email`, now() AS [[time]] ON DUPLICATE KEY UPDATE `ts`=:qp1, [[orders]]=T_upsert.orders + 1
158
-
SQL,
145
+
3 => 'INSERT INTO {{%T_upsert}} (`email`, [[ts]]) SELECT :phEmail AS `email`, CURRENT_TIMESTAMP AS [[ts]] ' .
'query, values and expressions without update part' => [
161
-
3 => <<<SQL
162
-
INSERT INTO {{%T_upsert}} (`email`, [[time]]) SELECT :phEmail AS `email`, now() AS [[time]] ON DUPLICATE KEY UPDATE `ts`=:qp1, [[orders]]=T_upsert.orders + 1
163
-
SQL,
149
+
3 => 'INSERT IGNORE INTO {{%T_upsert}} (`email`, [[ts]]) SELECT :phEmail AS `email`, CURRENT_TIMESTAMP AS [[ts]]',
164
150
],
165
151
'no columns to update' => [
166
-
3 => <<<SQL
167
-
INSERT INTO `T_upsert_1` (`a`) VALUES (:qp0) ON DUPLICATE KEY UPDATE `a`=`T_upsert_1`.`a`
168
-
SQL,
152
+
3 => 'INSERT IGNORE INTO `T_upsert_1` (`a`) VALUES (:qp0)',
169
153
],
170
-
// @todo - SQL code have a bug. Need fix in next PR
171
154
'no columns to update with unique' => [
172
-
3 => 'INSERT INTO {{%T_upsert}} (`email`) VALUES (:qp0) ON DUPLICATE KEY UPDATE ',
155
+
3 => 'INSERT IGNORE INTO {{%T_upsert}} (`email`) VALUES (:qp0)',
156
+
],
157
+
'no unique columns in table - simple insert' => [
158
+
3 => 'INSERT INTO {{%animal}} (`type`) VALUES (:qp0)',
0 commit comments