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

Support for NEW keyword in expression #162

Closed
touyu opened this issue Sep 29, 2021 · 0 comments · Fixed by #163
Closed

Support for NEW keyword in expression #162

touyu opened this issue Sep 29, 2021 · 0 comments · Fixed by #163

Comments

@touyu
Copy link
Contributor

touyu commented Sep 29, 2021

--export output

CREATE TABLE `users` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `logical_uniqueness` tinyint(1) DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

Input SQL

CREATE TRIGGER set_logical_uniqueness_on_users BEFORE UPDATE ON users FOR EACH ROW
SET NEW.logical_uniqueness = CASE 
    WHEN NEW.deleted_at IS NULL THEN 1 	
    WHEN NEW.deleted_at IS NOT NULL THEN NULL 
END;

Current output

found syntax error when parsing DDL "CREATE TRIGGER set_logical_uniqueness_on_users BEFORE UPDATE ON users FOR EACH ROW
SET NEW.logical_uniqueness = CASE
	WHEN NEW.deleted_at is null then 1
	WHEN NEW.deleted_at is not null then null
END": syntax error at position 128 near 'new'

Expected output

-- Apply --
CREATE TRIGGER set_logical_uniqueness_on_users BEFORE UPDATE ON users FOR EACH ROW SET NEW.logical_uniqueness = CASE WHEN NEW.deleted_at IS NULL THEN 1 WHEN NEW.deleted_at IS NOT NULL THEN NULL END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant