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
I am using MySQL as the materialized datastore of an event stream.
Each table has a primary key of id, and a date field.
Currently I have to do something like this to ensure that we always create a record, and only update if the event is newer than the previously stored record.
INSERT IGNORE INTO tbl_name (id, date, name) VALUES ('...', '...', ...);
UPDATE tbl_name SETdate='...', name ='...'WHERE id ='...'ANDdate<'...';
To me it seems that I can't use AS row_alias in sea-query to build my SQL string, which prevents me from writing the following sql:
INSERT INTO tbl_name (id, date, ...) VALUES ('...', '...', ...) AS new
ON DUPLICATE KEY UPDATE
name= (CASE WHEN ((new.date) >date) THEN new.name ELSE name END)
date= (CASE WHEN ((new.date) >date) THEN new.date ELSE date END);
Is this a known issue with the library or did I miss something in the documentation that would allow me to use the AS row_alias syntax?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I am using MySQL as the materialized datastore of an event stream.
Each table has a primary key of
id, and a date field.Currently I have to do something like this to ensure that we always create a record, and only update if the event is newer than the previously stored record.
I'm trying to replace that with a insert on duplicate key update statement as described in the MySQL reference manual and the insert statement manual.
As per that document a valid sql statement can be:
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO] tbl_name [PARTITION (partition_name [, partition_name] ...)] [(col_name [, col_name] ...)] { {VALUES | VALUE} (value_list) [, (value_list)] ... } [AS row_alias[(col_alias [, col_alias] ...)]] [ON DUPLICATE KEY UPDATE assignment_list]To me it seems that I can't use
AS row_aliasin sea-query to build my SQL string, which prevents me from writing the following sql:Is this a known issue with the library or did I miss something in the documentation that would allow me to use the
AS row_aliassyntax?Beta Was this translation helpful? Give feedback.
All reactions