Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mssqldef: Error when parsing UPDATE statement with FROM caluse. #444

Open
odz opened this issue Sep 16, 2023 · 0 comments
Open

mssqldef: Error when parsing UPDATE statement with FROM caluse. #444

odz opened this issue Sep 16, 2023 · 0 comments
Assignees
Labels
mssqldef Bugs or feature requests related to SQL Server

Comments

@odz
Copy link
Contributor

odz commented Sep 16, 2023

Platform

  • OS: Linux
  • RDBMS: SQL Server
  • Version: 0.16.7

Current Schema

CREATE TABLE reservation (
  id BIGINT NOT NULL IDENTITY (1, 1),
  start_time DATETIME2(0) NOT NULL,
  end_time DATETIME2(0) NOT NULL,
  reserve_time INTEGER,
  CONSTRAINT reservation_pk PRIMARY KEY CLUSTERED (id)
);
GO

CREATE TRIGGER reservation_insert ON reservation
INSTEAD OF UPDATE
AS
SET NOCOUNT ON
UPDATE reservation
SET
  start_time = inserted.start_time,
  end_time = inserted.end_time,
  reserve_time = DATEDIFF(second, inserted.start_time, inserted.end_time)
FROM inserted
WHERE reservation.id = inserted.id
GO

Current output (--export)

2023/09/17 02:23:13 found syntax error when parsing DDL "CREATE TRIGGER reservation_insert ON reservation
INSTEAD OF UPDATE
AS
SET NOCOUNT ON
UPDATE reservation
SET
  start_time = inserted.start_time,
  end_time = inserted.end_time,
  reserve_time = DATEDIFF(second, inserted.start_time, inserted.end_time)
FROM inserted
WHERE reservation.id = inserted.id
": syntax error at position 255 near 'from'

Expected output (--export)

CREATE TABLE reservation (
  id BIGINT NOT NULL IDENTITY (1, 1),
  start_time DATETIME2(0) NOT NULL,
  end_time DATETIME2(0) NOT NULL,
  reserve_time INTEGER,
  CONSTRAINT reservation_pk PRIMARY KEY CLUSTERED (id)
);
GO

CREATE TRIGGER reservation_insert ON reservation
INSTEAD OF UPDATE
AS
SET NOCOUNT ON
UPDATE reservation
SET
  start_time = inserted.start_time,
  end_time = inserted.end_time,
  reserve_time = DATEDIFF(second, inserted.start_time, inserted.end_time)
FROM inserted
WHERE reservation.id = inserted.id
GO
@odz odz self-assigned this Sep 16, 2023
@k0kubun k0kubun added the mssqldef Bugs or feature requests related to SQL Server label Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mssqldef Bugs or feature requests related to SQL Server
Projects
None yet
Development

No branches or pull requests

2 participants