CeresDB / sqlness

An ergonomic, opinionated framework for SQL integration test.
https://crates.io/crates/sqlness
Apache License 2.0
22 stars 7 forks source link

bug: split sql wrongly like `INSERT INTO timestamp VALUES ('1900-1-1 00;00;00');` #68

Closed discord9 closed 4 months ago

discord9 commented 4 months ago

Describe this problem

Current version of sqlness parse sql wrongly and will split this sql into three separate ones:

INSERT INTO timestamp VALUES ('1900-1-1 00;00;00');

This is due to this place simply split sql by ; instead of checking it semantic meaning: https://github.com/CeresDB/sqlness/blob/5469532cdaf87791b3af5d7e2918e92725f8dfc5/sqlness/src/case.rs#L157

// An intercetor may generate multiple SQLs, so we need to split them.
        for sql in sql.split(QUERY_DELIMITER) {

Steps to reproduce

CREATE TABLE timestamp(t TIMESTAMP time index);

INSERT INTO timestamp VALUES ('1900-1-1 00;00;00');

will make sqlness think the last sql is three sql:

INSERT INTO timestamp VALUES ('1900-1-1 00;
00;
00');

Expected behavior

not splitting sql

Additional Information

No response

waynexia commented 4 months ago

Looks like this regression was introduced in https://github.com/CeresDB/sqlness/pull/63 cc @jiacai2050

We need to make a new release after this is fixed. Maybe 0.6.1? If we don't class #67 as a breaking change.

jiacai2050 commented 4 months ago

Why you use ; in time string, shouldn't it be :?

discord9 commented 4 months ago

Why you use ; in time string, shouldn't it be :?

It's a test for parsing incorrect timestamp, so many corner cases for handling timestamp are covered

jiacai2050 commented 4 months ago

Got it.

I already submit a PR fix this, will make a release today.

jiacai2050 commented 4 months ago

Here it is.

waynexia commented 4 months ago

Thank you @jiacai2050 👍