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

fix: update num-bigint and add id to views #28

Merged
merged 2 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions src/sql/postgresql_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ impl PostgresqlGenerator {
CREATE VIEW "{contract_schema}"."{table}_live" AS (
SELECT
ctx.level as level,
level_meta.baked_at as level_timestamp
level_meta.baked_at as level_timestamp,
t.id
{columns}
FROM "{contract_schema}"."{table}" t
JOIN tx_contexts ctx
Expand All @@ -259,7 +260,8 @@ CREATE VIEW "{contract_schema}"."{table}_ordered" AS (
COALESCE(ctx.internal_number, -1)
) AS ordering,
ctx.level as level,
level_meta.baked_at as level_timestamp
level_meta.baked_at as level_timestamp,
t.id
{columns}
FROM "{contract_schema}"."{table}" t
JOIN tx_contexts ctx
Expand Down Expand Up @@ -291,7 +293,8 @@ CREATE VIEW "{contract_schema}"."{table}_ordered" AS (
CREATE VIEW "{contract_schema}"."{table}_live" AS (
SELECT
level,
level_timestamp
level_timestamp,
t.id
{columns}
FROM (
SELECT DISTINCT ON({indices})
Expand Down Expand Up @@ -327,12 +330,14 @@ CREATE VIEW "{contract_schema}"."{table}_ordered" AS (
) AS ordering,
ctx.level as level,
level_meta.baked_at as level_timestamp,
t.deleted
t.deleted,
t.id
{columns}
FROM (
SELECT
t.tx_context_id,
t.deleted
t.deleted,
t.id
{columns}
FROM "{contract_schema}"."{table}" t
WHERE t.deleted
Expand All @@ -342,7 +347,8 @@ CREATE VIEW "{contract_schema}"."{table}_ordered" AS (

SELECT
clr.tx_context_id,
'true' as deleted
'true' as deleted,
t.id
{columns}
FROM "{contract_schema}"."{table}" t
JOIN "{contract_schema}".bigmap_clears clr
Expand Down