sea-query icon indicating copy to clipboard operation
sea-query copied to clipboard

Invalid window definitions in sqlite

Open uttarayan21 opened this issue 1 year ago • 1 comments

Description

According to the window-defn page in sqlite.org All window definitions in sqlite should have a brace around them but the generated sql for sqlite doesn't do that.

Steps to Reproduce

Use sea_query::query::SelectStatement::window function and build the sql query for sqlite

Expected Behavior

FROM
    "image_metadata" AS "meta"
    INNER JOIN "image_core_metadata" AS "core_meta" ON "meta"."image" = "core_meta"."image"
WHERE
    "meta"."dupe" IS NOT NULL 
WINDOW "d_time" AS (PARTITION BY "meta"."dupe" ORDER BY "core_meta"."timestamp" ASC)

Actual Behavior

FROM
    "image_metadata" AS "meta"
    INNER JOIN "image_core_metadata" AS "core_meta" ON "meta"."image" = "core_meta"."image"
WHERE
    "meta"."dupe" IS NOT NULL 
WINDOW "d_time" AS PARTITION BY "meta"."dupe" ORDER BY "core_meta"."timestamp" ASC

Reproduces How Often

Always reproduced

Versions

Using sea-query 0.30.7

Additional Information

I'll provide a minimal reproducible example soon.

uttarayan21 avatar Apr 09 '24 06:04 uttarayan21

postgres requires the parenthesis aswell See: https://www.postgresql.org/docs/current/sql-select.html

WINDOW window_name AS ( window_definition ) [, ...]

Karechta avatar May 18 '25 03:05 Karechta