[Tarantool-patches] [PATCH v3 1/2] sql: use unify pattern for column names

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Thu Jul 2 00:25:48 MSK 2020


>>> +test:do_execsql2_test(
>>> +    "colname-12.5",
>>> +    [[
>>> +        CREATE TABLE j (s1 SCALAR PRIMARY KEY);
>>> +        INSERT INTO j VALUES(1);
>>> +    ]], {})
>>> +
>>> +--
>>> +-- Column named as 'COLUMN_1', because 's1 + 1' is a expression.
>>> +--
>>> +test:do_execsql2_test(
>>> +    "colname-12.6",
>>> +    [[
>>> +        SELECT s1 + 1 FROM j;
>>> +    ]], {
>>> +        "COLUMN_1",2
>>> +    })
>>> +
>>> +test:do_execsql2_test(
>>> +    "colname-12.7",
>>> +    [[
>>> +        SELECT s1 + 1 FROM j ORDER BY column_1;
>>> +    ]], {
>>> +        "COLUMN_1",2
>>> +    })
>>> +
>>> +test:do_execsql2_test(
>>> +    "colname-12.8",
>>> +    [[
>>> +        SELECT * FROM (SELECT s1 + 1 FROM j
>>> +                       ORDER BY column_1) ORDER BY column_1;
>>> +    ]], {
>>> +        "COLUMN_1",2
>>> +    })
>>> +
>>> +test:do_execsql2_test(
>>> +    "colname-12.9",
>>> +    [[
>>> +        SELECT s1 + 1 FROM j GROUP BY column_1;
>>> +    ]], {
>>> +        "COLUMN_1",2
>>> +    })
>>> +
>>> +test:do_execsql2_test(
>>> +    "colname-12.10",
>>> +    [[
>>> +        SELECT * FROM (SELECT s1 + 1 FROM j
>>> +                       ORDER BY column_1) GROUP BY column_1;
>>> +    ]], {
>>> +        "COLUMN_1",2
>>> +    })
>>> +
>>> +test:do_execsql2_test(
>>> +    "colname-12.11",
>>> +    [[
>>> +        SELECT * FROM (SELECT s1 + 1 FROM j
>>> +                       ORDER BY column_1) WHERE column_1 = 2;
>>> +    ]], {
>>> +        "COLUMN_1",2
>>> +    })
>>> +
>>> +test:do_execsql2_test(
>>> +    "colname-12.12",
>>> +    [[
>>> +        SELECT *, s1 + 1 FROM j ORDER BY column_1;
>>> +    ]], {
>>> +        "S1",1,"COLUMN_1",2
>>> +    })
>>> +
>>> +test:do_execsql2_test(
>>> +    "colname-12.13",
>>> +    [[
>>> +        SELECT s1 + 1, * FROM j ORDER BY column_1;
>>> +    ]], {
>>> +        "COLUMN_1",2,"S1",1
>>> +    })
>>> +
>>> +test:do_execsql2_test(
>>> +    "colname-12.14",
>>> +    [[
>>> +        CREATE TABLE j_1 (column_1 SCALAR PRIMARY KEY, column_2 SCALAR);
>>> +        INSERT INTO j_1 VALUES(1, 1);
>>> +    ]], {})
>>> +
>>> +test:do_execsql2_test(
>>> +    "colname-12.15",
>>> +    [[
>>> +        SELECT column_1, column_1 + 1, column_2, 2 FROM j_1;
>>> +    ]], {
>>> +        "COLUMN_1",1,"COLUMN_1",2,"COLUMN_2",1,"COLUMN_2",2
>>> +    })
>>> +
>>
>> Is there a test on how ORDER BY selects a column?
> Did you mean this? If it is not a bug,  we should document that, because
> because this is not obvious behavior, IMO.

Yes, I mean this. It does not depend on whether this is a bug. If
something is a bug, or is not documented, it does not mean it
shouldn't be tested.

You can add this to the doc request.


More information about the Tarantool-patches mailing list