Skip to content

Commit 4dacca8

Browse files
committed
Replace || use in Query.duplicate for mysql
Mysql doesn't use || for concat, unless set as a mode. Cleaned up code here.
1 parent 5119daa commit 4dacca8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pysimplesql/pysimplesql.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1221,13 +1221,16 @@ def duplicate_record(self, cascade=True):
12211221
## This can be done using * syntax without having to know the schema of the table
12221222
## (other than the name of the primary key). The trick is to create a temporary table
12231223
## using the "CREATE TABLE AS" syntax.
1224-
q = f'CREATE TEMPORARY TABLE tmp AS SELECT * FROM {self.table} WHERE {self.pk_column}={self.get_current(self.pk_column)}'
1224+
pk = self.get_current(self.pk_column)
1225+
description = self.get_description_for_pk(pk)
1226+
1227+
q = f'CREATE TEMPORARY TABLE tmp AS SELECT * FROM {self.table} WHERE {self.pk_column}={pk}'
12251228
self.driver.execute(q)
12261229
logger.debug(q)
12271230
q = f'UPDATE tmp SET {self.pk_column} = NULL'
12281231
self.driver.execute(q)
12291232
logger.debug(q)
1230-
q = f'UPDATE tmp SET {self.description_column} = "Copy of " || {self.description_column}'
1233+
q = f'UPDATE tmp SET {self.description_column} = "Copy of {description}"'
12311234
self.driver.execute(q)
12321235
logger.debug(q)
12331236
q = f'INSERT INTO {self.table} SELECT * FROM tmp'

0 commit comments

Comments
 (0)