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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 BUG: D1 Database triggers bypass D1 data type validation #5786

Open
conqr2 opened this issue May 8, 2024 · 0 comments
Open

馃悰 BUG: D1 Database triggers bypass D1 data type validation #5786

conqr2 opened this issue May 8, 2024 · 0 comments
Labels
bug Something that isn't working

Comments

@conqr2
Copy link

conqr2 commented May 8, 2024

Which Cloudflare product(s) does this pertain to?

D1

What version(s) of the tool(s) are you using?

3.53.1 [Wrangler]

What version of Node are you using?

No response

What operating system and version are you using?

Mac Ventura 13.5.2

Describe the Bug

Observed behavior

Triggers can bypass column data type validation when updating a row

Expected behavior

Triggers should be restricted by a column's data type when performing updates

Steps to reproduce

  • Setup:
CREATE TABLE IF NOT EXISTS test (
    id TEXT PRIMARY KEY NOT NULL,
    val INTEGER NOT NULL
);

CREATE TRIGGER update_on_change AFTER
UPDATE OF val ON test FOR EACH ROW
BEGIN
UPDATE test
SET
    val = 'not_an_integer'
WHERE
    id = NEW.id;

END;

INSERT INTO test (id, val) VALUES ('test', 1);
  • Trigger the trigger:
UPDATE test SET val=2 WHERE id='test'
  • the val column of the test row (val is defined as an Integer) now contains Text

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

@conqr2 conqr2 added the bug Something that isn't working label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
Status: Untriaged
Development

No branches or pull requests

1 participant