From eab54b259d043b8e03001ac733b42c3b246efd05 Mon Sep 17 00:00:00 2001 From: Alexandre Macabies Date: Fri, 1 Oct 2021 04:17:37 +0200 Subject: [PATCH] Add a Makefile for the terrible sqlx codegen-in-workspace workaround. https://github.com/launchbadge/sqlx/issues/1223#issuecomment-931833548 [rust] --- Makefile | 7 ++ sqlx-data.json | 224 +------------------------------------------------ 2 files changed, 8 insertions(+), 223 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5f466b6 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +.PHONY: sqlx +sqlx: + rm -rf target/sqlx + env -u DATABASE_URL SQLX_OFFLINE=false cargo check --workspace + $(eval DB=$(shell jq .db sqlx-data.json)) + jq --compact-output -s '{"db": $(DB)} + (INDEX(.hash)|to_entries|sort_by(.key)|from_entries)' target/sqlx/query-*.json > sqlx-data.json.tmp || ( rm sqlx-data.json.tmp && exit 1 ) + mv -f sqlx-data.json.tmp sqlx-data.json diff --git a/sqlx-data.json b/sqlx-data.json index c7a4501..fe64fe3 100644 --- a/sqlx-data.json +++ b/sqlx-data.json @@ -1,223 +1 @@ -{ - "db": "PostgreSQL", - "110b3f2c068b321832bfce7877da1a5c61f35eb45cca58b8ee0dc7f24bb7cd20": { - "query": "\n SELECT max(\"timestamp\") \"timestamp\" FROM \"message\" WHERE \"channel\" = $1\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "timestamp", - "type_info": "Timestamptz" - } - ], - "parameters": { - "Left": [ - "Text" - ] - }, - "nullable": [ - null - ] - }, - "hash": "110b3f2c068b321832bfce7877da1a5c61f35eb45cca58b8ee0dc7f24bb7cd20" - }, - "30a701311c632fa7d9ed3f71cee2c712aaf2cf780b54345eb6eca83d0d3839f9": { - "query": "SELECT FROM \"message\" WHERE \"channel\" = $1 LIMIT 1", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Text" - ] - }, - "nullable": [] - }, - "hash": "30a701311c632fa7d9ed3f71cee2c712aaf2cf780b54345eb6eca83d0d3839f9" - }, - "71ec0d36a295fefcf658667274cad526a1f60ea546137da5bde1627e79eb7b2c": { - "query": "\n SELECT DISTINCT EXTRACT(DAY FROM \"timestamp\") \"day!\"\n FROM \"message\"\n WHERE \"channel\" = $1 AND (\"opcode\" IS NULL OR \"opcode\" = 'me')\n AND \"timestamp\" >= $2 AND \"timestamp\" < $3\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "day!", - "type_info": "Float8" - } - ], - "parameters": { - "Left": [ - "Text", - "Timestamptz", - "Timestamptz" - ] - }, - "nullable": [ - null - ] - }, - "hash": "71ec0d36a295fefcf658667274cad526a1f60ea546137da5bde1627e79eb7b2c" - }, - "8f971cc0fff34f50fe0128db92b089d60eb11d9307f155c79fba49be9d1682cf": { - "query": "\n WITH \"query\" AS (\n SELECT row(\"message\".*) \"message!:Message\",\n ts_headline('english', \"line\", plainto_tsquery('english', $2), U&'StartSel=\\E000, StopSel=\\E001') \"headline!\"\n FROM \"message\"\n WHERE \"channel\" || '' = $1\n AND coalesce(\"opcode\", '') = ''\n AND CASE WHEN $2 = '' THEN TRUE ELSE to_tsvector('english', \"nick\" || ' ' || \"line\") @@ plainto_tsquery('english', $2) END\n AND CASE WHEN $5 = '' THEN TRUE ELSE \"nick\" LIKE $5 END\n )\n SELECT *, COUNT(*) OVER () \"total!\"\n FROM \"query\" t LIMIT $3 OFFSET $4\n", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "message!:Message", - "type_info": "Record" - }, - { - "ordinal": 1, - "name": "headline!", - "type_info": "Text" - }, - { - "ordinal": 2, - "name": "total!", - "type_info": "Int8" - } - ], - "parameters": { - "Left": [ - "Text", - "Text", - "Int8", - "Int8", - "Text" - ] - }, - "nullable": [ - null, - null, - null - ] - }, - "hash": "8f971cc0fff34f50fe0128db92b089d60eb11d9307f155c79fba49be9d1682cf" - }, - "b129c80562d66cacc7346ec228afe395bafed773f6594528107b63e8abf29bbc": { - "query": "SELECT \"channel\" FROM all_channels()", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "channel", - "type_info": "Text" - } - ], - "parameters": { - "Left": [] - }, - "nullable": [ - null - ] - }, - "hash": "b129c80562d66cacc7346ec228afe395bafed773f6594528107b63e8abf29bbc" - }, - "b7e1d8bfea3f36ffadbd4a71024e692fa48a11290b313a19b8224638bb269405": { - "query": "\n WITH \"ts\" AS (SELECT min(\"timestamp\") \"first!\", max(\"timestamp\") \"last!\" FROM \"message\" WHERE \"channel\" = $1)\n SELECT \"first!\", \"last!\", array(SELECT \"nick\" FROM all_nicks($1, $2)) \"nicks!\",\n (SELECT row(\"message\".*) FROM \"message\"\n WHERE \"channel\" = $1 AND \"opcode\" = 'topic' AND coalesce(\"payload\", '') != '' AND \"timestamp\" < $3\n ORDER BY \"timestamp\" DESC LIMIT 1) \"topic?:Message\"\n FROM \"ts\" GROUP BY 1, 2, 3 LIMIT 1\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "first!", - "type_info": "Timestamptz" - }, - { - "ordinal": 1, - "name": "last!", - "type_info": "Timestamptz" - }, - { - "ordinal": 2, - "name": "nicks!", - "type_info": "TextArray" - }, - { - "ordinal": 3, - "name": "topic?:Message", - "type_info": "Record" - } - ], - "parameters": { - "Left": [ - "Text", - "Numeric", - "Timestamptz" - ] - }, - "nullable": [ - null, - null, - null, - null - ] - }, - "hash": "b7e1d8bfea3f36ffadbd4a71024e692fa48a11290b313a19b8224638bb269405" - }, - "e8eb7e07555d7abb03d488e6ef76ee395896e7137bc6f2257a8521c536c0ad7e": { - "query": "\n SELECT * FROM \"message\"\n WHERE \"channel\" = $1 AND \"timestamp\" >= $2 AND \"timestamp\" < $3\n ORDER BY \"timestamp\"\n LIMIT $4\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Int4" - }, - { - "ordinal": 1, - "name": "channel", - "type_info": "Text" - }, - { - "ordinal": 2, - "name": "nick", - "type_info": "Text" - }, - { - "ordinal": 3, - "name": "line", - "type_info": "Text" - }, - { - "ordinal": 4, - "name": "opcode", - "type_info": "Text" - }, - { - "ordinal": 5, - "name": "oper_nick", - "type_info": "Text" - }, - { - "ordinal": 6, - "name": "payload", - "type_info": "Text" - }, - { - "ordinal": 7, - "name": "timestamp", - "type_info": "Timestamptz" - } - ], - "parameters": { - "Left": [ - "Text", - "Timestamptz", - "Timestamptz", - "Int8" - ] - }, - "nullable": [ - false, - true, - true, - true, - true, - true, - true, - false - ] - }, - "hash": "e8eb7e07555d7abb03d488e6ef76ee395896e7137bc6f2257a8521c536c0ad7e" - } -} +{"db":"PostgreSQL","110b3f2c068b321832bfce7877da1a5c61f35eb45cca58b8ee0dc7f24bb7cd20":{"query":"\n SELECT max(\"timestamp\") \"timestamp\" FROM \"message\" WHERE \"channel\" = $1\n ","describe":{"columns":[{"ordinal":0,"name":"timestamp","type_info":"Timestamptz"}],"parameters":{"Left":["Text"]},"nullable":[null]},"hash":"110b3f2c068b321832bfce7877da1a5c61f35eb45cca58b8ee0dc7f24bb7cd20"},"30a701311c632fa7d9ed3f71cee2c712aaf2cf780b54345eb6eca83d0d3839f9":{"query":"SELECT FROM \"message\" WHERE \"channel\" = $1 LIMIT 1","describe":{"columns":[],"parameters":{"Left":["Text"]},"nullable":[]},"hash":"30a701311c632fa7d9ed3f71cee2c712aaf2cf780b54345eb6eca83d0d3839f9"},"71ec0d36a295fefcf658667274cad526a1f60ea546137da5bde1627e79eb7b2c":{"query":"\n SELECT DISTINCT EXTRACT(DAY FROM \"timestamp\") \"day!\"\n FROM \"message\"\n WHERE \"channel\" = $1 AND (\"opcode\" IS NULL OR \"opcode\" = 'me')\n AND \"timestamp\" >= $2 AND \"timestamp\" < $3\n ","describe":{"columns":[{"ordinal":0,"name":"day!","type_info":"Float8"}],"parameters":{"Left":["Text","Timestamptz","Timestamptz"]},"nullable":[null]},"hash":"71ec0d36a295fefcf658667274cad526a1f60ea546137da5bde1627e79eb7b2c"},"8f971cc0fff34f50fe0128db92b089d60eb11d9307f155c79fba49be9d1682cf":{"query":"\n WITH \"query\" AS (\n SELECT row(\"message\".*) \"message!:Message\",\n ts_headline('english', \"line\", plainto_tsquery('english', $2), U&'StartSel=\\E000, StopSel=\\E001') \"headline!\"\n FROM \"message\"\n WHERE \"channel\" || '' = $1\n AND coalesce(\"opcode\", '') = ''\n AND CASE WHEN $2 = '' THEN TRUE ELSE to_tsvector('english', \"nick\" || ' ' || \"line\") @@ plainto_tsquery('english', $2) END\n AND CASE WHEN $5 = '' THEN TRUE ELSE \"nick\" LIKE $5 END\n )\n SELECT *, COUNT(*) OVER () \"total!\"\n FROM \"query\" t LIMIT $3 OFFSET $4\n","describe":{"columns":[{"ordinal":0,"name":"message!:Message","type_info":"Record"},{"ordinal":1,"name":"headline!","type_info":"Text"},{"ordinal":2,"name":"total!","type_info":"Int8"}],"parameters":{"Left":["Text","Text","Int8","Int8","Text"]},"nullable":[null,null,null]},"hash":"8f971cc0fff34f50fe0128db92b089d60eb11d9307f155c79fba49be9d1682cf"},"b129c80562d66cacc7346ec228afe395bafed773f6594528107b63e8abf29bbc":{"query":"SELECT \"channel\" FROM all_channels()","describe":{"columns":[{"ordinal":0,"name":"channel","type_info":"Text"}],"parameters":{"Left":[]},"nullable":[null]},"hash":"b129c80562d66cacc7346ec228afe395bafed773f6594528107b63e8abf29bbc"},"b7e1d8bfea3f36ffadbd4a71024e692fa48a11290b313a19b8224638bb269405":{"query":"\n WITH \"ts\" AS (SELECT min(\"timestamp\") \"first!\", max(\"timestamp\") \"last!\" FROM \"message\" WHERE \"channel\" = $1)\n SELECT \"first!\", \"last!\", array(SELECT \"nick\" FROM all_nicks($1, $2)) \"nicks!\",\n (SELECT row(\"message\".*) FROM \"message\"\n WHERE \"channel\" = $1 AND \"opcode\" = 'topic' AND coalesce(\"payload\", '') != '' AND \"timestamp\" < $3\n ORDER BY \"timestamp\" DESC LIMIT 1) \"topic?:Message\"\n FROM \"ts\" GROUP BY 1, 2, 3 LIMIT 1\n ","describe":{"columns":[{"ordinal":0,"name":"first!","type_info":"Timestamptz"},{"ordinal":1,"name":"last!","type_info":"Timestamptz"},{"ordinal":2,"name":"nicks!","type_info":"TextArray"},{"ordinal":3,"name":"topic?:Message","type_info":"Record"}],"parameters":{"Left":["Text","Numeric","Timestamptz"]},"nullable":[null,null,null,null]},"hash":"b7e1d8bfea3f36ffadbd4a71024e692fa48a11290b313a19b8224638bb269405"},"e8eb7e07555d7abb03d488e6ef76ee395896e7137bc6f2257a8521c536c0ad7e":{"query":"\n SELECT * FROM \"message\"\n WHERE \"channel\" = $1 AND \"timestamp\" >= $2 AND \"timestamp\" < $3\n ORDER BY \"timestamp\"\n LIMIT $4\n ","describe":{"columns":[{"ordinal":0,"name":"id","type_info":"Int4"},{"ordinal":1,"name":"channel","type_info":"Text"},{"ordinal":2,"name":"nick","type_info":"Text"},{"ordinal":3,"name":"line","type_info":"Text"},{"ordinal":4,"name":"opcode","type_info":"Text"},{"ordinal":5,"name":"oper_nick","type_info":"Text"},{"ordinal":6,"name":"payload","type_info":"Text"},{"ordinal":7,"name":"timestamp","type_info":"Timestamptz"}],"parameters":{"Left":["Text","Timestamptz","Timestamptz","Int8"]},"nullable":[false,true,true,true,true,true,true,false]},"hash":"e8eb7e07555d7abb03d488e6ef76ee395896e7137bc6f2257a8521c536c0ad7e"}}