diff --git a/.sqlx/query-0644481879afc3abad9188fde0b00d19638ff16d6c8678d8d4e54a4b6bf5393d.json b/.sqlx/query-0644481879afc3abad9188fde0b00d19638ff16d6c8678d8d4e54a4b6bf5393d.json new file mode 100644 index 0000000..693a99f --- /dev/null +++ b/.sqlx/query-0644481879afc3abad9188fde0b00d19638ff16d6c8678d8d4e54a4b6bf5393d.json @@ -0,0 +1,85 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n b.id,\n b.title,\n b.lang,\n b.file_type,\n b.year,\n CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS \"available_types!: Vec\",\n b.uploaded,\n (\n SELECT\n JSONB_AGG(\n JSONB_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM book_authors\n JOIN authors ON authors.id = book_authors.author\n WHERE book_authors.book = b.id\n ) AS \"authors!: Vec\",\n (\n SELECT\n JSONB_AGG(\n JSONB_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM translations\n JOIN authors ON authors.id = translations.author\n WHERE translations.book = b.id\n ) AS \"translators!: Vec\",\n EXISTS(\n SELECT * FROM book_annotations WHERE book = b.id\n ) AS \"annotation_exists!: bool\",\n bs.position\n FROM books b\n JOIN book_sequences bs ON b.id = bs.book\n WHERE\n b.is_deleted = FALSE AND\n bs.sequence = $1 AND\n b.lang = ANY($2)\n ORDER BY bs.position\n LIMIT $3 OFFSET $4\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int4" + }, + { + "ordinal": 1, + "name": "title", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "lang", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "file_type", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "year", + "type_info": "Int2" + }, + { + "ordinal": 5, + "name": "available_types!: Vec", + "type_info": "TextArray" + }, + { + "ordinal": 6, + "name": "uploaded", + "type_info": "Date" + }, + { + "ordinal": 7, + "name": "authors!: Vec", + "type_info": "Jsonb" + }, + { + "ordinal": 8, + "name": "translators!: Vec", + "type_info": "Jsonb" + }, + { + "ordinal": 9, + "name": "annotation_exists!: bool", + "type_info": "Bool" + }, + { + "ordinal": 10, + "name": "position", + "type_info": "Int2" + } + ], + "parameters": { + "Left": [ + "Int4", + "TextArray", + "Int8", + "Int8" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + null, + false, + null, + null, + null, + false + ] + }, + "hash": "0644481879afc3abad9188fde0b00d19638ff16d6c8678d8d4e54a4b6bf5393d" +} diff --git a/.sqlx/query-34c2b0f605eddd776433543f2a553324ab61277083a0b6a41f1c43edc596ed60.json b/.sqlx/query-34c2b0f605eddd776433543f2a553324ab61277083a0b6a41f1c43edc596ed60.json deleted file mode 100644 index e49f2ef..0000000 --- a/.sqlx/query-34c2b0f605eddd776433543f2a553324ab61277083a0b6a41f1c43edc596ed60.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT\n b.id,\n b.title,\n b.lang,\n b.file_type,\n b.year,\n CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS \"available_types!: Vec\",\n b.uploaded,\n (\n SELECT\n JSON_AGG(\n JSON_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM book_authors\n JOIN authors ON authors.id = book_authors.author\n WHERE book_authors.book = b.id\n ) AS \"authors!: Vec\",\n (\n SELECT\n JSON_AGG(\n JSON_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM translations\n JOIN authors ON authors.id = translations.author\n WHERE translations.book = b.id\n ) AS \"translators!: Vec\",\n EXISTS(\n SELECT * FROM book_annotations WHERE book = b.id\n ) AS \"annotation_exists!: bool\",\n bs.position\n FROM books b\n JOIN book_sequences bs ON b.id = bs.book\n WHERE\n b.is_deleted = FALSE AND\n bs.sequence = $1 AND\n b.lang = ANY($2)\n ORDER BY bs.position\n LIMIT $3 OFFSET $4\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Int4" - }, - { - "ordinal": 1, - "name": "title", - "type_info": "Varchar" - }, - { - "ordinal": 2, - "name": "lang", - "type_info": "Varchar" - }, - { - "ordinal": 3, - "name": "file_type", - "type_info": "Varchar" - }, - { - "ordinal": 4, - "name": "year", - "type_info": "Int2" - }, - { - "ordinal": 5, - "name": "available_types!: Vec", - "type_info": "TextArray" - }, - { - "ordinal": 6, - "name": "uploaded", - "type_info": "Date" - }, - { - "ordinal": 7, - "name": "authors!: Vec", - "type_info": "Json" - }, - { - "ordinal": 8, - "name": "translators!: Vec", - "type_info": "Json" - }, - { - "ordinal": 9, - "name": "annotation_exists!: bool", - "type_info": "Bool" - }, - { - "ordinal": 10, - "name": "position", - "type_info": "Int2" - } - ], - "parameters": { - "Left": [ - "Int4", - "TextArray", - "Int8", - "Int8" - ] - }, - "nullable": [ - false, - false, - false, - false, - false, - null, - false, - null, - null, - null, - false - ] - }, - "hash": "34c2b0f605eddd776433543f2a553324ab61277083a0b6a41f1c43edc596ed60" -} diff --git a/.sqlx/query-3bf3d8ef40b6832eeeb1b5e01a3d7b5ce9586fad68f8f502adfb3cd2f372f0c8.json b/.sqlx/query-3bf3d8ef40b6832eeeb1b5e01a3d7b5ce9586fad68f8f502adfb3cd2f372f0c8.json deleted file mode 100644 index d3b6d4c..0000000 --- a/.sqlx/query-3bf3d8ef40b6832eeeb1b5e01a3d7b5ce9586fad68f8f502adfb3cd2f372f0c8.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT\n b.id,\n b.title,\n b.lang,\n b.file_type,\n b.year,\n CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS \"available_types!: Vec\",\n b.uploaded,\n (\n SELECT\n JSON_AGG(\n JSON_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM book_authors\n JOIN authors ON authors.id = book_authors.author\n WHERE book_authors.book = b.id\n ) AS \"authors!: Vec\",\n (\n SELECT\n JSON_AGG(\n JSON_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM translations\n JOIN authors ON authors.id = translations.author\n WHERE translations.book = b.id\n ) AS \"translators!: Vec\",\n (\n SELECT\n JSON_AGG(\n JSON_BUILD_OBJECT(\n 'id', sequences.id,\n 'name', sequences.name\n )\n )\n FROM book_sequences\n JOIN sequences ON sequences.id = book_sequences.sequence\n WHERE book_sequences.book = b.id\n ) AS \"sequences!: Vec\",\n (\n SELECT\n JSON_AGG(\n JSON_BUILD_OBJECT(\n 'id', genres.id,\n 'code', genres.code,\n 'description', genres.description,\n 'meta', genres.meta,\n 'source', JSON_BUILD_OBJECT(\n 'id', sources.id,\n 'name', sources.name\n )\n )\n )\n FROM book_genres\n JOIN genres ON genres.id = book_genres.genre\n JOIN sources ON sources.id = genres.source\n WHERE book_genres.book = b.id\n ) AS \"genres!: Vec\",\n EXISTS(\n SELECT * FROM book_annotations WHERE book = b.id\n ) AS \"annotation_exists!: bool\",\n (\n SELECT\n JSON_BUILD_OBJECT(\n 'id', sources.id,\n 'name', sources.name\n )\n FROM sources\n WHERE sources.id = b.source\n ) AS \"source!: Source\",\n b.remote_id,\n b.is_deleted,\n b.pages\n FROM books b\n WHERE b.id = $1\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Int4" - }, - { - "ordinal": 1, - "name": "title", - "type_info": "Varchar" - }, - { - "ordinal": 2, - "name": "lang", - "type_info": "Varchar" - }, - { - "ordinal": 3, - "name": "file_type", - "type_info": "Varchar" - }, - { - "ordinal": 4, - "name": "year", - "type_info": "Int2" - }, - { - "ordinal": 5, - "name": "available_types!: Vec", - "type_info": "TextArray" - }, - { - "ordinal": 6, - "name": "uploaded", - "type_info": "Date" - }, - { - "ordinal": 7, - "name": "authors!: Vec", - "type_info": "Json" - }, - { - "ordinal": 8, - "name": "translators!: Vec", - "type_info": "Json" - }, - { - "ordinal": 9, - "name": "sequences!: Vec", - "type_info": "Json" - }, - { - "ordinal": 10, - "name": "genres!: Vec", - "type_info": "Json" - }, - { - "ordinal": 11, - "name": "annotation_exists!: bool", - "type_info": "Bool" - }, - { - "ordinal": 12, - "name": "source!: Source", - "type_info": "Json" - }, - { - "ordinal": 13, - "name": "remote_id", - "type_info": "Int4" - }, - { - "ordinal": 14, - "name": "is_deleted", - "type_info": "Bool" - }, - { - "ordinal": 15, - "name": "pages", - "type_info": "Int4" - } - ], - "parameters": { - "Left": [ - "Int4" - ] - }, - "nullable": [ - false, - false, - false, - false, - false, - null, - false, - null, - null, - null, - null, - null, - null, - false, - false, - true - ] - }, - "hash": "3bf3d8ef40b6832eeeb1b5e01a3d7b5ce9586fad68f8f502adfb3cd2f372f0c8" -} diff --git a/.sqlx/query-52cef4b1366f8071f42b772cfe32489050ce4d0b395cb0c93944389b1dfa8251.json b/.sqlx/query-52cef4b1366f8071f42b772cfe32489050ce4d0b395cb0c93944389b1dfa8251.json new file mode 100644 index 0000000..5465aa5 --- /dev/null +++ b/.sqlx/query-52cef4b1366f8071f42b772cfe32489050ce4d0b395cb0c93944389b1dfa8251.json @@ -0,0 +1,112 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n b.id,\n b.title,\n b.lang,\n b.file_type,\n b.year,\n CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS \"available_types!: Vec\",\n b.uploaded,\n (\n SELECT\n JSONB_AGG(\n JSONB_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM book_authors\n JOIN authors ON authors.id = book_authors.author\n WHERE book_authors.book = b.id\n ) AS \"authors!: Vec\",\n (\n SELECT\n JSONB_AGG(\n JSONB_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM translations\n JOIN authors ON authors.id = translations.author\n WHERE translations.book = b.id\n ) AS \"translators!: Vec\",\n (\n SELECT\n JSONB_AGG(\n JSONB_BUILD_OBJECT(\n 'id', sequences.id,\n 'name', sequences.name\n )\n )\n FROM book_sequences\n JOIN sequences ON sequences.id = book_sequences.sequence\n WHERE book_sequences.book = b.id\n ) AS \"sequences!: Vec\",\n (\n SELECT\n JSONB_AGG(\n JSONB_BUILD_OBJECT(\n 'id', genres.id,\n 'code', genres.code,\n 'description', genres.description,\n 'meta', genres.meta,\n 'source', JSONB_BUILD_OBJECT(\n 'id', sources.id,\n 'name', sources.name\n )\n )\n )\n FROM book_genres\n JOIN genres ON genres.id = book_genres.genre\n JOIN sources ON sources.id = genres.source\n WHERE book_genres.book = b.id\n ) AS \"genres!: Vec\",\n EXISTS(\n SELECT * FROM book_annotations WHERE book = b.id\n ) AS \"annotation_exists!: bool\",\n (\n SELECT\n JSONB_BUILD_OBJECT(\n 'id', sources.id,\n 'name', sources.name\n )\n FROM sources\n WHERE sources.id = b.source\n ) AS \"source!: Source\",\n b.remote_id,\n b.is_deleted,\n b.pages\n FROM books b\n WHERE b.id = $1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int4" + }, + { + "ordinal": 1, + "name": "title", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "lang", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "file_type", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "year", + "type_info": "Int2" + }, + { + "ordinal": 5, + "name": "available_types!: Vec", + "type_info": "TextArray" + }, + { + "ordinal": 6, + "name": "uploaded", + "type_info": "Date" + }, + { + "ordinal": 7, + "name": "authors!: Vec", + "type_info": "Jsonb" + }, + { + "ordinal": 8, + "name": "translators!: Vec", + "type_info": "Jsonb" + }, + { + "ordinal": 9, + "name": "sequences!: Vec", + "type_info": "Jsonb" + }, + { + "ordinal": 10, + "name": "genres!: Vec", + "type_info": "Jsonb" + }, + { + "ordinal": 11, + "name": "annotation_exists!: bool", + "type_info": "Bool" + }, + { + "ordinal": 12, + "name": "source!: Source", + "type_info": "Jsonb" + }, + { + "ordinal": 13, + "name": "remote_id", + "type_info": "Int4" + }, + { + "ordinal": 14, + "name": "is_deleted", + "type_info": "Bool" + }, + { + "ordinal": 15, + "name": "pages", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Int4" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + null, + false, + null, + null, + null, + null, + null, + null, + false, + false, + true + ] + }, + "hash": "52cef4b1366f8071f42b772cfe32489050ce4d0b395cb0c93944389b1dfa8251" +} diff --git a/.sqlx/query-5d232f0a9a4cd5bb05d5d246af878bb43fb042f8643bb1a9b98dbafde4fbf50b.json b/.sqlx/query-5d232f0a9a4cd5bb05d5d246af878bb43fb042f8643bb1a9b98dbafde4fbf50b.json deleted file mode 100644 index 52d0728..0000000 --- a/.sqlx/query-5d232f0a9a4cd5bb05d5d246af878bb43fb042f8643bb1a9b98dbafde4fbf50b.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT\n b.id,\n b.title,\n b.lang,\n b.file_type,\n b.year,\n CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS \"available_types!: Vec\",\n b.uploaded,\n (\n SELECT\n JSON_AGG(\n JSON_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM book_authors\n JOIN authors ON authors.id = book_authors.author\n WHERE book_authors.book = b.id\n ) AS \"authors!: Vec\",\n (\n SELECT\n JSON_AGG(\n JSON_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM translations\n JOIN authors ON authors.id = translations.author\n WHERE translations.book = b.id\n ) AS \"translators!: Vec\",\n (\n SELECT\n JSON_AGG(\n JSON_BUILD_OBJECT(\n 'id', sequences.id,\n 'name', sequences.name\n )\n )\n FROM book_sequences\n JOIN sequences ON sequences.id = book_sequences.sequence\n WHERE book_sequences.book = b.id\n ) AS \"sequences!: Vec\",\n EXISTS(\n SELECT * FROM book_annotations WHERE book = b.id\n ) AS \"annotation_exists!: bool\",\n (\n SELECT\n JSON_BUILD_OBJECT(\n 'id', sources.id,\n 'name', sources.name\n )\n FROM sources\n WHERE sources.id = b.source\n ) AS \"source!: Source\",\n b.remote_id\n FROM books b\n WHERE lang = ANY($1) AND\n ($2::boolean IS NULL OR is_deleted = $2) AND\n ($3::date IS NULL OR uploaded >= $3) AND\n ($4::date IS NULL OR uploaded <= $4) AND\n ($5::integer IS NULL OR id >= $5) AND\n ($6::integer IS NULL OR id <= $6)\n ORDER BY b.id ASC\n OFFSET $7\n LIMIT $8\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Int4" - }, - { - "ordinal": 1, - "name": "title", - "type_info": "Varchar" - }, - { - "ordinal": 2, - "name": "lang", - "type_info": "Varchar" - }, - { - "ordinal": 3, - "name": "file_type", - "type_info": "Varchar" - }, - { - "ordinal": 4, - "name": "year", - "type_info": "Int2" - }, - { - "ordinal": 5, - "name": "available_types!: Vec", - "type_info": "TextArray" - }, - { - "ordinal": 6, - "name": "uploaded", - "type_info": "Date" - }, - { - "ordinal": 7, - "name": "authors!: Vec", - "type_info": "Json" - }, - { - "ordinal": 8, - "name": "translators!: Vec", - "type_info": "Json" - }, - { - "ordinal": 9, - "name": "sequences!: Vec", - "type_info": "Json" - }, - { - "ordinal": 10, - "name": "annotation_exists!: bool", - "type_info": "Bool" - }, - { - "ordinal": 11, - "name": "source!: Source", - "type_info": "Json" - }, - { - "ordinal": 12, - "name": "remote_id", - "type_info": "Int4" - } - ], - "parameters": { - "Left": [ - "TextArray", - "Bool", - "Date", - "Date", - "Int4", - "Int4", - "Int8", - "Int8" - ] - }, - "nullable": [ - false, - false, - false, - false, - false, - null, - false, - null, - null, - null, - null, - null, - false - ] - }, - "hash": "5d232f0a9a4cd5bb05d5d246af878bb43fb042f8643bb1a9b98dbafde4fbf50b" -} diff --git a/.sqlx/query-d6aca7480253eca9b91da9f68aa7156aa3bcf6f8e2d743ea727a2f7abfb69f1b.json b/.sqlx/query-6f91dfb52d18d080bcaf1dfbf7b7d4b6a6168cc33312d767798815d802962ff9.json similarity index 61% rename from .sqlx/query-d6aca7480253eca9b91da9f68aa7156aa3bcf6f8e2d743ea727a2f7abfb69f1b.json rename to .sqlx/query-6f91dfb52d18d080bcaf1dfbf7b7d4b6a6168cc33312d767798815d802962ff9.json index e765aae..9d9a07a 100644 --- a/.sqlx/query-d6aca7480253eca9b91da9f68aa7156aa3bcf6f8e2d743ea727a2f7abfb69f1b.json +++ b/.sqlx/query-6f91dfb52d18d080bcaf1dfbf7b7d4b6a6168cc33312d767798815d802962ff9.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n b.id,\n b.title,\n b.lang,\n b.file_type,\n b.year,\n CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS \"available_types!: Vec\",\n b.uploaded,\n (\n SELECT\n JSON_AGG(\n JSON_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM translations\n JOIN authors ON authors.id = translations.author\n WHERE translations.book = b.id\n ) AS \"translators!: Vec\",\n (\n SELECT\n JSON_AGG(\n JSON_BUILD_OBJECT(\n 'id', sequences.id,\n 'name', sequences.name\n )\n )\n FROM book_sequences\n JOIN sequences ON sequences.id = book_sequences.sequence\n WHERE book_sequences.book = b.id\n ) AS \"sequences!: Vec\",\n EXISTS(\n SELECT * FROM book_annotations WHERE book = b.id\n ) AS \"annotation_exists!: bool\"\n FROM books b\n JOIN book_authors ba ON b.id = ba.book\n WHERE b.is_deleted = false AND ba.author = $1 AND b.lang = ANY($2)\n ORDER BY b.title ASC\n OFFSET $3\n LIMIT $4\n ", + "query": "\n SELECT\n b.id,\n b.title,\n b.lang,\n b.file_type,\n b.year,\n CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS \"available_types!: Vec\",\n b.uploaded,\n (\n SELECT\n JSONB_AGG(\n JSONB_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM book_authors\n JOIN authors ON authors.id = book_authors.author\n WHERE book_authors.book = b.id\n ) AS \"authors!: Vec\",\n (\n SELECT\n JSONB_AGG(\n JSONB_BUILD_OBJECT(\n 'id', sequences.id,\n 'name', sequences.name\n )\n )\n FROM book_sequences\n JOIN sequences ON sequences.id = book_sequences.sequence\n WHERE book_sequences.book = b.id\n ) AS \"sequences!: Vec\",\n EXISTS(\n SELECT * FROM book_annotations WHERE book = b.id\n ) AS \"annotation_exists!: bool\"\n FROM books b\n ", "describe": { "columns": [ { @@ -40,13 +40,13 @@ }, { "ordinal": 7, - "name": "translators!: Vec", - "type_info": "Json" + "name": "authors!: Vec", + "type_info": "Jsonb" }, { "ordinal": 8, "name": "sequences!: Vec", - "type_info": "Json" + "type_info": "Jsonb" }, { "ordinal": 9, @@ -55,12 +55,7 @@ } ], "parameters": { - "Left": [ - "Int4", - "TextArray", - "Int8", - "Int8" - ] + "Left": [] }, "nullable": [ false, @@ -75,5 +70,5 @@ null ] }, - "hash": "d6aca7480253eca9b91da9f68aa7156aa3bcf6f8e2d743ea727a2f7abfb69f1b" + "hash": "6f91dfb52d18d080bcaf1dfbf7b7d4b6a6168cc33312d767798815d802962ff9" } diff --git a/.sqlx/query-b0ed6a54e198e8388620cc9cf12deed4ce2f7c539c912caa0c6f3b46c8f8835f.json b/.sqlx/query-763625de44f46e1183a1ca2760120ce0303b571ffbc4e5f544340b5134229940.json similarity index 67% rename from .sqlx/query-b0ed6a54e198e8388620cc9cf12deed4ce2f7c539c912caa0c6f3b46c8f8835f.json rename to .sqlx/query-763625de44f46e1183a1ca2760120ce0303b571ffbc4e5f544340b5134229940.json index 7f42a30..76cfb6d 100644 --- a/.sqlx/query-b0ed6a54e198e8388620cc9cf12deed4ce2f7c539c912caa0c6f3b46c8f8835f.json +++ b/.sqlx/query-763625de44f46e1183a1ca2760120ce0303b571ffbc4e5f544340b5134229940.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n genres.id,\n genres.remote_id,\n genres.code,\n genres.description,\n genres.meta,\n (\n SELECT\n JSON_BUILD_OBJECT(\n 'id', sources.id,\n 'name', sources.name\n )\n FROM sources\n WHERE sources.id = genres.source\n ) AS \"source!: Source\"\n FROM genres\n ORDER BY genres.id ASC\n ", + "query": "\n SELECT\n genres.id,\n genres.remote_id,\n genres.code,\n genres.description,\n genres.meta,\n (\n SELECT\n JSONB_BUILD_OBJECT(\n 'id', sources.id,\n 'name', sources.name\n )\n FROM sources\n WHERE sources.id = genres.source\n ) AS \"source!: Source\"\n FROM genres\n ORDER BY genres.id ASC\n ", "describe": { "columns": [ { @@ -31,7 +31,7 @@ { "ordinal": 5, "name": "source!: Source", - "type_info": "Json" + "type_info": "Jsonb" } ], "parameters": { @@ -46,5 +46,5 @@ null ] }, - "hash": "b0ed6a54e198e8388620cc9cf12deed4ce2f7c539c912caa0c6f3b46c8f8835f" + "hash": "763625de44f46e1183a1ca2760120ce0303b571ffbc4e5f544340b5134229940" } diff --git a/.sqlx/query-8050a82de1de70e6ca60a02227795a263774da36fb00b97b00ed4ecd9a7ec778.json b/.sqlx/query-8050a82de1de70e6ca60a02227795a263774da36fb00b97b00ed4ecd9a7ec778.json new file mode 100644 index 0000000..5351a64 --- /dev/null +++ b/.sqlx/query-8050a82de1de70e6ca60a02227795a263774da36fb00b97b00ed4ecd9a7ec778.json @@ -0,0 +1,101 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n b.id,\n b.title,\n b.lang,\n b.file_type,\n b.year,\n CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS \"available_types!: Vec\",\n b.uploaded,\n (\n SELECT\n JSONB_AGG(\n JSONB_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM book_authors\n JOIN authors ON authors.id = book_authors.author\n WHERE book_authors.book = b.id\n ) AS \"authors!: Vec\",\n (\n SELECT\n JSONB_AGG(\n JSONB_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM translations\n JOIN authors ON authors.id = translations.author\n WHERE translations.book = b.id\n ) AS \"translators!: Vec\",\n (\n SELECT\n JSONB_AGG(\n JSONB_BUILD_OBJECT(\n 'id', sequences.id,\n 'name', sequences.name\n )\n )\n FROM book_sequences\n JOIN sequences ON sequences.id = book_sequences.sequence\n WHERE book_sequences.book = b.id\n ) AS \"sequences!: Vec\",\n EXISTS(\n SELECT * FROM book_annotations WHERE book = b.id\n ) AS \"annotation_exists!: bool\",\n (\n SELECT\n JSONB_BUILD_OBJECT(\n 'id', sources.id,\n 'name', sources.name\n )\n FROM sources\n WHERE sources.id = b.source\n ) AS \"source!: Source\",\n b.remote_id\n FROM books b\n WHERE lang = ANY($1) AND\n ($2::boolean IS NULL OR is_deleted = $2) AND\n ($3::date IS NULL OR uploaded >= $3) AND\n ($4::date IS NULL OR uploaded <= $4) AND\n ($5::integer IS NULL OR id >= $5) AND\n ($6::integer IS NULL OR id <= $6)\n ORDER BY b.id ASC\n OFFSET $7\n LIMIT $8\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int4" + }, + { + "ordinal": 1, + "name": "title", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "lang", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "file_type", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "year", + "type_info": "Int2" + }, + { + "ordinal": 5, + "name": "available_types!: Vec", + "type_info": "TextArray" + }, + { + "ordinal": 6, + "name": "uploaded", + "type_info": "Date" + }, + { + "ordinal": 7, + "name": "authors!: Vec", + "type_info": "Jsonb" + }, + { + "ordinal": 8, + "name": "translators!: Vec", + "type_info": "Jsonb" + }, + { + "ordinal": 9, + "name": "sequences!: Vec", + "type_info": "Jsonb" + }, + { + "ordinal": 10, + "name": "annotation_exists!: bool", + "type_info": "Bool" + }, + { + "ordinal": 11, + "name": "source!: Source", + "type_info": "Jsonb" + }, + { + "ordinal": 12, + "name": "remote_id", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "TextArray", + "Bool", + "Date", + "Date", + "Int4", + "Int4", + "Int8", + "Int8" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + null, + false, + null, + null, + null, + null, + null, + false + ] + }, + "hash": "8050a82de1de70e6ca60a02227795a263774da36fb00b97b00ed4ecd9a7ec778" +} diff --git a/.sqlx/query-daada7d7552a41a8d44a4f7b3d62bc804f3f4944166d8e168e1a3a91f2ff4bc9.json b/.sqlx/query-868081a73c2ee8e44db3d19d82afed39949d5310dfccdea2bbda1086f8ff9120.json similarity index 65% rename from .sqlx/query-daada7d7552a41a8d44a4f7b3d62bc804f3f4944166d8e168e1a3a91f2ff4bc9.json rename to .sqlx/query-868081a73c2ee8e44db3d19d82afed39949d5310dfccdea2bbda1086f8ff9120.json index 6c0338d..feec415 100644 --- a/.sqlx/query-daada7d7552a41a8d44a4f7b3d62bc804f3f4944166d8e168e1a3a91f2ff4bc9.json +++ b/.sqlx/query-868081a73c2ee8e44db3d19d82afed39949d5310dfccdea2bbda1086f8ff9120.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n genres.id,\n genres.remote_id,\n genres.code,\n genres.description,\n genres.meta,\n (\n SELECT\n JSON_BUILD_OBJECT(\n 'id', sources.id,\n 'name', sources.name\n )\n FROM sources\n WHERE sources.id = genres.source\n ) AS \"source!: Source\"\n FROM genres\n WHERE (meta = $1 OR $1 IS NULL)\n ORDER BY genres.id ASC\n LIMIT $2 OFFSET $3\n ", + "query": "\n SELECT\n genres.id,\n genres.remote_id,\n genres.code,\n genres.description,\n genres.meta,\n (\n SELECT\n JSONB_BUILD_OBJECT(\n 'id', sources.id,\n 'name', sources.name\n )\n FROM sources\n WHERE sources.id = genres.source\n ) AS \"source!: Source\"\n FROM genres\n WHERE (meta = $1 OR $1 IS NULL)\n ORDER BY genres.id ASC\n LIMIT $2 OFFSET $3\n ", "describe": { "columns": [ { @@ -31,7 +31,7 @@ { "ordinal": 5, "name": "source!: Source", - "type_info": "Json" + "type_info": "Jsonb" } ], "parameters": { @@ -50,5 +50,5 @@ null ] }, - "hash": "daada7d7552a41a8d44a4f7b3d62bc804f3f4944166d8e168e1a3a91f2ff4bc9" + "hash": "868081a73c2ee8e44db3d19d82afed39949d5310dfccdea2bbda1086f8ff9120" } diff --git a/.sqlx/query-91845687097ff0ce0f2f1dd51d2b61d2abf1cd2f04c2b3371f32720501c5f790.json b/.sqlx/query-91845687097ff0ce0f2f1dd51d2b61d2abf1cd2f04c2b3371f32720501c5f790.json new file mode 100644 index 0000000..1bd18c2 --- /dev/null +++ b/.sqlx/query-91845687097ff0ce0f2f1dd51d2b61d2abf1cd2f04c2b3371f32720501c5f790.json @@ -0,0 +1,79 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n b.id,\n b.title,\n b.lang,\n b.file_type,\n b.year,\n CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS \"available_types!: Vec\",\n b.uploaded,\n (\n SELECT\n JSONB_AGG(\n JSONB_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM translations\n JOIN authors ON authors.id = translations.author\n WHERE translations.book = b.id\n ) AS \"translators!: Vec\",\n (\n SELECT\n JSONB_AGG(\n JSONB_BUILD_OBJECT(\n 'id', sequences.id,\n 'name', sequences.name\n )\n )\n FROM book_sequences\n JOIN sequences ON sequences.id = book_sequences.sequence\n WHERE book_sequences.book = b.id\n ) AS \"sequences!: Vec\",\n EXISTS(\n SELECT * FROM book_annotations WHERE book = b.id\n ) AS \"annotation_exists!: bool\"\n FROM books b\n JOIN book_authors ba ON b.id = ba.book\n WHERE b.is_deleted = false AND ba.author = $1 AND b.lang = ANY($2)\n ORDER BY b.title ASC\n OFFSET $3\n LIMIT $4\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int4" + }, + { + "ordinal": 1, + "name": "title", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "lang", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "file_type", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "year", + "type_info": "Int2" + }, + { + "ordinal": 5, + "name": "available_types!: Vec", + "type_info": "TextArray" + }, + { + "ordinal": 6, + "name": "uploaded", + "type_info": "Date" + }, + { + "ordinal": 7, + "name": "translators!: Vec", + "type_info": "Jsonb" + }, + { + "ordinal": 8, + "name": "sequences!: Vec", + "type_info": "Jsonb" + }, + { + "ordinal": 9, + "name": "annotation_exists!: bool", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Int4", + "TextArray", + "Int8", + "Int8" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + null, + false, + null, + null, + null + ] + }, + "hash": "91845687097ff0ce0f2f1dd51d2b61d2abf1cd2f04c2b3371f32720501c5f790" +} diff --git a/.sqlx/query-92f7e43d41bb56fe9ef3207ff4f870e12a02347d479dcda39c72f0ff2fe6a6fd.json b/.sqlx/query-92f7e43d41bb56fe9ef3207ff4f870e12a02347d479dcda39c72f0ff2fe6a6fd.json deleted file mode 100644 index d3ae2fa..0000000 --- a/.sqlx/query-92f7e43d41bb56fe9ef3207ff4f870e12a02347d479dcda39c72f0ff2fe6a6fd.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT\n b.id,\n b.title,\n b.lang,\n b.file_type,\n b.year,\n CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS \"available_types!: Vec\",\n b.uploaded,\n (\n SELECT\n JSON_AGG(\n JSON_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM book_authors\n JOIN authors ON authors.id = book_authors.author\n WHERE book_authors.book = b.id\n ) AS \"authors!: Vec\",\n (\n SELECT\n JSON_AGG(\n JSON_BUILD_OBJECT(\n 'id', sequences.id,\n 'name', sequences.name\n )\n )\n FROM book_sequences\n JOIN sequences ON sequences.id = book_sequences.sequence\n WHERE book_sequences.book = b.id\n ) AS \"sequences!: Vec\",\n EXISTS(\n SELECT * FROM book_annotations WHERE book = b.id\n ) AS \"annotation_exists!: bool\"\n FROM books b\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Int4" - }, - { - "ordinal": 1, - "name": "title", - "type_info": "Varchar" - }, - { - "ordinal": 2, - "name": "lang", - "type_info": "Varchar" - }, - { - "ordinal": 3, - "name": "file_type", - "type_info": "Varchar" - }, - { - "ordinal": 4, - "name": "year", - "type_info": "Int2" - }, - { - "ordinal": 5, - "name": "available_types!: Vec", - "type_info": "TextArray" - }, - { - "ordinal": 6, - "name": "uploaded", - "type_info": "Date" - }, - { - "ordinal": 7, - "name": "authors!: Vec", - "type_info": "Json" - }, - { - "ordinal": 8, - "name": "sequences!: Vec", - "type_info": "Json" - }, - { - "ordinal": 9, - "name": "annotation_exists!: bool", - "type_info": "Bool" - } - ], - "parameters": { - "Left": [] - }, - "nullable": [ - false, - false, - false, - false, - false, - null, - false, - null, - null, - null - ] - }, - "hash": "92f7e43d41bb56fe9ef3207ff4f870e12a02347d479dcda39c72f0ff2fe6a6fd" -} diff --git a/.sqlx/query-c270823ac20835ebeba0fca557c8bb237bf9f4fa7c5b1956e2cf491b01ae30b0.json b/.sqlx/query-c270823ac20835ebeba0fca557c8bb237bf9f4fa7c5b1956e2cf491b01ae30b0.json new file mode 100644 index 0000000..7afb30a --- /dev/null +++ b/.sqlx/query-c270823ac20835ebeba0fca557c8bb237bf9f4fa7c5b1956e2cf491b01ae30b0.json @@ -0,0 +1,82 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n b.id,\n b.title,\n b.lang,\n b.file_type,\n b.year,\n CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS \"available_types!: Vec\",\n b.uploaded,\n (\n SELECT\n JSONB_AGG(\n JSONB_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM book_authors\n JOIN authors ON authors.id = book_authors.author\n WHERE book_authors.book = b.id\n ) AS \"authors!: Vec\",\n (\n SELECT\n JSONB_AGG(\n JSONB_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM translations\n JOIN authors ON authors.id = translations.author\n WHERE translations.book = b.id\n ) AS \"translators!: Vec\",\n (\n SELECT\n JSONB_AGG(\n JSONB_BUILD_OBJECT(\n 'id', sequences.id,\n 'name', sequences.name\n )\n )\n FROM book_sequences\n JOIN sequences ON sequences.id = book_sequences.sequence\n WHERE book_sequences.book = b.id\n ) AS \"sequences!: Vec\",\n EXISTS(\n SELECT * FROM book_annotations WHERE book = b.id\n ) AS \"annotation_exists!: bool\"\n FROM books b\n WHERE b.id = ANY($1)\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int4" + }, + { + "ordinal": 1, + "name": "title", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "lang", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "file_type", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "year", + "type_info": "Int2" + }, + { + "ordinal": 5, + "name": "available_types!: Vec", + "type_info": "TextArray" + }, + { + "ordinal": 6, + "name": "uploaded", + "type_info": "Date" + }, + { + "ordinal": 7, + "name": "authors!: Vec", + "type_info": "Jsonb" + }, + { + "ordinal": 8, + "name": "translators!: Vec", + "type_info": "Jsonb" + }, + { + "ordinal": 9, + "name": "sequences!: Vec", + "type_info": "Jsonb" + }, + { + "ordinal": 10, + "name": "annotation_exists!: bool", + "type_info": "Bool" + } + ], + "parameters": { + "Left": [ + "Int4Array" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + null, + false, + null, + null, + null, + null + ] + }, + "hash": "c270823ac20835ebeba0fca557c8bb237bf9f4fa7c5b1956e2cf491b01ae30b0" +} diff --git a/.sqlx/query-cedb65e8561dfff84cfab1eac28e03f082ea8190a47283fb6662e2d9a6246c57.json b/.sqlx/query-cedb65e8561dfff84cfab1eac28e03f082ea8190a47283fb6662e2d9a6246c57.json deleted file mode 100644 index 58ce4cc..0000000 --- a/.sqlx/query-cedb65e8561dfff84cfab1eac28e03f082ea8190a47283fb6662e2d9a6246c57.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT\n b.id,\n b.title,\n b.lang,\n b.file_type,\n b.year,\n CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS \"available_types!: Vec\",\n b.uploaded,\n (\n SELECT\n JSON_AGG(\n JSON_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM book_authors\n JOIN authors ON authors.id = book_authors.author\n WHERE book_authors.book = b.id\n ) AS \"authors!: Vec\",\n (\n SELECT\n JSON_AGG(\n JSON_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM translations\n JOIN authors ON authors.id = translations.author\n WHERE translations.book = b.id\n ) AS \"translators!: Vec\",\n (\n SELECT\n JSON_AGG(\n JSON_BUILD_OBJECT(\n 'id', sequences.id,\n 'name', sequences.name\n )\n )\n FROM book_sequences\n JOIN sequences ON sequences.id = book_sequences.sequence\n WHERE book_sequences.book = b.id\n ) AS \"sequences!: Vec\",\n EXISTS(\n SELECT * FROM book_annotations WHERE book = b.id\n ) AS \"annotation_exists!: bool\"\n FROM books b\n WHERE b.id = ANY($1)\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Int4" - }, - { - "ordinal": 1, - "name": "title", - "type_info": "Varchar" - }, - { - "ordinal": 2, - "name": "lang", - "type_info": "Varchar" - }, - { - "ordinal": 3, - "name": "file_type", - "type_info": "Varchar" - }, - { - "ordinal": 4, - "name": "year", - "type_info": "Int2" - }, - { - "ordinal": 5, - "name": "available_types!: Vec", - "type_info": "TextArray" - }, - { - "ordinal": 6, - "name": "uploaded", - "type_info": "Date" - }, - { - "ordinal": 7, - "name": "authors!: Vec", - "type_info": "Json" - }, - { - "ordinal": 8, - "name": "translators!: Vec", - "type_info": "Json" - }, - { - "ordinal": 9, - "name": "sequences!: Vec", - "type_info": "Json" - }, - { - "ordinal": 10, - "name": "annotation_exists!: bool", - "type_info": "Bool" - } - ], - "parameters": { - "Left": [ - "Int4Array" - ] - }, - "nullable": [ - false, - false, - false, - false, - false, - null, - false, - null, - null, - null, - null - ] - }, - "hash": "cedb65e8561dfff84cfab1eac28e03f082ea8190a47283fb6662e2d9a6246c57" -} diff --git a/.sqlx/query-df08b13f0f084e01ce2e5d9e31ed1dc0e7499483f1bbcdafc2b85c5ad0e3b956.json b/.sqlx/query-df08b13f0f084e01ce2e5d9e31ed1dc0e7499483f1bbcdafc2b85c5ad0e3b956.json deleted file mode 100644 index 3dd039d..0000000 --- a/.sqlx/query-df08b13f0f084e01ce2e5d9e31ed1dc0e7499483f1bbcdafc2b85c5ad0e3b956.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT\n b.id,\n b.title,\n b.lang,\n b.file_type,\n b.year,\n CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS \"available_types!: Vec\",\n b.uploaded,\n (\n SELECT\n JSON_AGG(\n JSON_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM book_authors\n JOIN authors ON authors.id = book_authors.author\n WHERE book_authors.book = b.id\n ) AS \"authors!: Vec\",\n (\n SELECT\n JSON_AGG(\n JSON_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM translations\n JOIN authors ON authors.id = translations.author\n WHERE translations.book = b.id\n ) AS \"translators!: Vec\",\n (\n SELECT\n JSON_AGG(\n JSON_BUILD_OBJECT(\n 'id', sequences.id,\n 'name', sequences.name\n )\n )\n FROM book_sequences\n JOIN sequences ON sequences.id = book_sequences.sequence\n WHERE book_sequences.book = b.id\n ) AS \"sequences!: Vec\",\n (\n SELECT\n JSON_AGG(\n JSON_BUILD_OBJECT(\n 'id', genres.id,\n 'code', genres.code,\n 'description', genres.description,\n 'meta', genres.meta,\n 'source', JSON_BUILD_OBJECT(\n 'id', sources.id,\n 'name', sources.name\n )\n )\n )\n FROM book_genres\n JOIN genres ON genres.id = book_genres.genre\n JOIN sources ON sources.id = genres.source\n WHERE book_genres.book = b.id\n ) AS \"genres!: Vec\",\n EXISTS(\n SELECT * FROM book_annotations WHERE book = b.id\n ) AS \"annotation_exists!: bool\",\n (\n SELECT\n JSON_BUILD_OBJECT(\n 'id', sources.id,\n 'name', sources.name\n )\n FROM sources\n WHERE sources.id = b.source\n ) AS \"source!: Source\",\n b.remote_id,\n b.is_deleted,\n b.pages\n FROM books b\n WHERE b.source = $1 AND b.remote_id = $2\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Int4" - }, - { - "ordinal": 1, - "name": "title", - "type_info": "Varchar" - }, - { - "ordinal": 2, - "name": "lang", - "type_info": "Varchar" - }, - { - "ordinal": 3, - "name": "file_type", - "type_info": "Varchar" - }, - { - "ordinal": 4, - "name": "year", - "type_info": "Int2" - }, - { - "ordinal": 5, - "name": "available_types!: Vec", - "type_info": "TextArray" - }, - { - "ordinal": 6, - "name": "uploaded", - "type_info": "Date" - }, - { - "ordinal": 7, - "name": "authors!: Vec", - "type_info": "Json" - }, - { - "ordinal": 8, - "name": "translators!: Vec", - "type_info": "Json" - }, - { - "ordinal": 9, - "name": "sequences!: Vec", - "type_info": "Json" - }, - { - "ordinal": 10, - "name": "genres!: Vec", - "type_info": "Json" - }, - { - "ordinal": 11, - "name": "annotation_exists!: bool", - "type_info": "Bool" - }, - { - "ordinal": 12, - "name": "source!: Source", - "type_info": "Json" - }, - { - "ordinal": 13, - "name": "remote_id", - "type_info": "Int4" - }, - { - "ordinal": 14, - "name": "is_deleted", - "type_info": "Bool" - }, - { - "ordinal": 15, - "name": "pages", - "type_info": "Int4" - } - ], - "parameters": { - "Left": [ - "Int2", - "Int4" - ] - }, - "nullable": [ - false, - false, - false, - false, - false, - null, - false, - null, - null, - null, - null, - null, - null, - false, - false, - true - ] - }, - "hash": "df08b13f0f084e01ce2e5d9e31ed1dc0e7499483f1bbcdafc2b85c5ad0e3b956" -} diff --git a/.sqlx/query-e6cf55988b86d72c594915c9e5a015d71106794415fb267d6f71d512e9831012.json b/.sqlx/query-e6cf55988b86d72c594915c9e5a015d71106794415fb267d6f71d512e9831012.json new file mode 100644 index 0000000..7d03754 --- /dev/null +++ b/.sqlx/query-e6cf55988b86d72c594915c9e5a015d71106794415fb267d6f71d512e9831012.json @@ -0,0 +1,113 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n b.id,\n b.title,\n b.lang,\n b.file_type,\n b.year,\n CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS \"available_types!: Vec\",\n b.uploaded,\n (\n SELECT\n JSONB_AGG(\n JSONB_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM book_authors\n JOIN authors ON authors.id = book_authors.author\n WHERE book_authors.book = b.id\n ) AS \"authors!: Vec\",\n (\n SELECT\n JSONB_AGG(\n JSONB_BUILD_OBJECT(\n 'id', authors.id,\n 'first_name', authors.first_name,\n 'last_name', authors.last_name,\n 'middle_name', authors.middle_name,\n 'annotation_exists', EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )\n )\n FROM translations\n JOIN authors ON authors.id = translations.author\n WHERE translations.book = b.id\n ) AS \"translators!: Vec\",\n (\n SELECT\n JSONB_AGG(\n JSONB_BUILD_OBJECT(\n 'id', sequences.id,\n 'name', sequences.name\n )\n )\n FROM book_sequences\n JOIN sequences ON sequences.id = book_sequences.sequence\n WHERE book_sequences.book = b.id\n ) AS \"sequences!: Vec\",\n (\n SELECT\n JSONB_AGG(\n JSONB_BUILD_OBJECT(\n 'id', genres.id,\n 'code', genres.code,\n 'description', genres.description,\n 'meta', genres.meta,\n 'source', JSONB_BUILD_OBJECT(\n 'id', sources.id,\n 'name', sources.name\n )\n )\n )\n FROM book_genres\n JOIN genres ON genres.id = book_genres.genre\n JOIN sources ON sources.id = genres.source\n WHERE book_genres.book = b.id\n ) AS \"genres!: Vec\",\n EXISTS(\n SELECT * FROM book_annotations WHERE book = b.id\n ) AS \"annotation_exists!: bool\",\n (\n SELECT\n JSONB_BUILD_OBJECT(\n 'id', sources.id,\n 'name', sources.name\n )\n FROM sources\n WHERE sources.id = b.source\n ) AS \"source!: Source\",\n b.remote_id,\n b.is_deleted,\n b.pages\n FROM books b\n WHERE b.source = $1 AND b.remote_id = $2\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Int4" + }, + { + "ordinal": 1, + "name": "title", + "type_info": "Varchar" + }, + { + "ordinal": 2, + "name": "lang", + "type_info": "Varchar" + }, + { + "ordinal": 3, + "name": "file_type", + "type_info": "Varchar" + }, + { + "ordinal": 4, + "name": "year", + "type_info": "Int2" + }, + { + "ordinal": 5, + "name": "available_types!: Vec", + "type_info": "TextArray" + }, + { + "ordinal": 6, + "name": "uploaded", + "type_info": "Date" + }, + { + "ordinal": 7, + "name": "authors!: Vec", + "type_info": "Jsonb" + }, + { + "ordinal": 8, + "name": "translators!: Vec", + "type_info": "Jsonb" + }, + { + "ordinal": 9, + "name": "sequences!: Vec", + "type_info": "Jsonb" + }, + { + "ordinal": 10, + "name": "genres!: Vec", + "type_info": "Jsonb" + }, + { + "ordinal": 11, + "name": "annotation_exists!: bool", + "type_info": "Bool" + }, + { + "ordinal": 12, + "name": "source!: Source", + "type_info": "Jsonb" + }, + { + "ordinal": 13, + "name": "remote_id", + "type_info": "Int4" + }, + { + "ordinal": 14, + "name": "is_deleted", + "type_info": "Bool" + }, + { + "ordinal": 15, + "name": "pages", + "type_info": "Int4" + } + ], + "parameters": { + "Left": [ + "Int2", + "Int4" + ] + }, + "nullable": [ + false, + false, + false, + false, + false, + null, + false, + null, + null, + null, + null, + null, + null, + false, + false, + true + ] + }, + "hash": "e6cf55988b86d72c594915c9e5a015d71106794415fb267d6f71d512e9831012" +} diff --git a/src/serializers/author.rs b/src/serializers/author.rs index 040323c..e08813a 100644 --- a/src/serializers/author.rs +++ b/src/serializers/author.rs @@ -23,7 +23,7 @@ pub struct AuthorBook { pub available_types: Vec, #[serde(serialize_with = "naive_date_serializer::serialize")] pub uploaded: NaiveDate, - pub translators: Vec, - pub sequences: Vec, + pub translators: sqlx::types::Json>, + pub sequences: sqlx::types::Json>, pub annotation_exists: bool, } diff --git a/src/serializers/book.rs b/src/serializers/book.rs index a342505..3bf5118 100644 --- a/src/serializers/book.rs +++ b/src/serializers/book.rs @@ -81,8 +81,8 @@ pub struct Book { pub available_types: Vec, #[serde(serialize_with = "naive_date_serializer::serialize")] pub uploaded: NaiveDate, - pub authors: Vec, - pub translators: Vec, - pub sequences: Vec, + pub authors: sqlx::types::Json>, + pub translators: sqlx::types::Json>, + pub sequences: sqlx::types::Json>, pub annotation_exists: bool, } diff --git a/src/serializers/sequence.rs b/src/serializers/sequence.rs index 3d59b19..cef544e 100644 --- a/src/serializers/sequence.rs +++ b/src/serializers/sequence.rs @@ -20,8 +20,8 @@ pub struct SequenceBook { pub available_types: Vec, #[serde(serialize_with = "naive_date_serializer::serialize")] pub uploaded: NaiveDate, - pub authors: Vec, - pub translators: Vec, + pub authors: sqlx::types::Json>, + pub translators: sqlx::types::Json>, pub annotation_exists: bool, pub position: i32, } diff --git a/src/serializers/translator.rs b/src/serializers/translator.rs index 080ff43..35f333d 100644 --- a/src/serializers/translator.rs +++ b/src/serializers/translator.rs @@ -15,7 +15,7 @@ pub struct TranslatorBook { pub available_types: Vec, #[serde(serialize_with = "naive_date_serializer::serialize")] pub uploaded: NaiveDate, - pub authors: Vec, - pub sequences: Vec, + pub authors: sqlx::types::Json>, + pub sequences: sqlx::types::Json>, pub annotation_exists: bool, } diff --git a/src/views/authors.rs b/src/views/authors.rs index 364d81e..6a81396 100644 --- a/src/views/authors.rs +++ b/src/views/authors.rs @@ -216,8 +216,8 @@ async fn get_author_books( b.uploaded, ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', authors.id, 'first_name', authors.first_name, 'last_name', authors.last_name, @@ -233,8 +233,8 @@ async fn get_author_books( ) AS "translators!: Vec", ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', sequences.id, 'name', sequences.name ) diff --git a/src/views/books.rs b/src/views/books.rs index b96fb20..c11aefc 100644 --- a/src/views/books.rs +++ b/src/views/books.rs @@ -62,8 +62,8 @@ pub async fn get_books( b.uploaded, ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', authors.id, 'first_name', authors.first_name, 'last_name', authors.last_name, @@ -79,8 +79,8 @@ pub async fn get_books( ) AS "authors!: Vec", ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', authors.id, 'first_name', authors.first_name, 'last_name', authors.last_name, @@ -96,8 +96,8 @@ pub async fn get_books( ) AS "translators!: Vec", ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', sequences.id, 'name', sequences.name ) @@ -111,7 +111,7 @@ pub async fn get_books( ) AS "annotation_exists!: bool", ( SELECT - JSON_BUILD_OBJECT( + JSONB_BUILD_OBJECT( 'id', sources.id, 'name', sources.name ) @@ -245,8 +245,8 @@ pub async fn get_random_book( b.uploaded, ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', authors.id, 'first_name', authors.first_name, 'last_name', authors.last_name, @@ -262,8 +262,8 @@ pub async fn get_random_book( ) AS "authors!: Vec", ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', authors.id, 'first_name', authors.first_name, 'last_name', authors.last_name, @@ -279,8 +279,8 @@ pub async fn get_random_book( ) AS "translators!: Vec", ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', sequences.id, 'name', sequences.name ) @@ -291,13 +291,13 @@ pub async fn get_random_book( ) AS "sequences!: Vec", ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', genres.id, 'code', genres.code, 'description', genres.description, 'meta', genres.meta, - 'source', JSON_BUILD_OBJECT( + 'source', JSONB_BUILD_OBJECT( 'id', sources.id, 'name', sources.name ) @@ -313,7 +313,7 @@ pub async fn get_random_book( ) AS "annotation_exists!: bool", ( SELECT - JSON_BUILD_OBJECT( + JSONB_BUILD_OBJECT( 'id', sources.id, 'name', sources.name ) @@ -353,8 +353,8 @@ pub async fn get_remote_book( b.uploaded, ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', authors.id, 'first_name', authors.first_name, 'last_name', authors.last_name, @@ -370,8 +370,8 @@ pub async fn get_remote_book( ) AS "authors!: Vec", ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', authors.id, 'first_name', authors.first_name, 'last_name', authors.last_name, @@ -387,8 +387,8 @@ pub async fn get_remote_book( ) AS "translators!: Vec", ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', sequences.id, 'name', sequences.name ) @@ -399,13 +399,13 @@ pub async fn get_remote_book( ) AS "sequences!: Vec", ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', genres.id, 'code', genres.code, 'description', genres.description, 'meta', genres.meta, - 'source', JSON_BUILD_OBJECT( + 'source', JSONB_BUILD_OBJECT( 'id', sources.id, 'name', sources.name ) @@ -421,7 +421,7 @@ pub async fn get_remote_book( ) AS "annotation_exists!: bool", ( SELECT - JSON_BUILD_OBJECT( + JSONB_BUILD_OBJECT( 'id', sources.id, 'name', sources.name ) @@ -491,8 +491,8 @@ pub async fn search_books( b.uploaded, ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', authors.id, 'first_name', authors.first_name, 'last_name', authors.last_name, @@ -508,8 +508,8 @@ pub async fn search_books( ) AS "authors!: Vec", ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', authors.id, 'first_name', authors.first_name, 'last_name', authors.last_name, @@ -525,8 +525,8 @@ pub async fn search_books( ) AS "translators!: Vec", ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', sequences.id, 'name', sequences.name ) @@ -573,8 +573,8 @@ pub async fn get_book(db: Database, Path(book_id): Path) -> impl IntoRespon b.uploaded, ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', authors.id, 'first_name', authors.first_name, 'last_name', authors.last_name, @@ -590,8 +590,8 @@ pub async fn get_book(db: Database, Path(book_id): Path) -> impl IntoRespon ) AS "authors!: Vec", ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', authors.id, 'first_name', authors.first_name, 'last_name', authors.last_name, @@ -607,8 +607,8 @@ pub async fn get_book(db: Database, Path(book_id): Path) -> impl IntoRespon ) AS "translators!: Vec", ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', sequences.id, 'name', sequences.name ) @@ -619,13 +619,13 @@ pub async fn get_book(db: Database, Path(book_id): Path) -> impl IntoRespon ) AS "sequences!: Vec", ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', genres.id, 'code', genres.code, 'description', genres.description, 'meta', genres.meta, - 'source', JSON_BUILD_OBJECT( + 'source', JSONB_BUILD_OBJECT( 'id', sources.id, 'name', sources.name ) @@ -641,7 +641,7 @@ pub async fn get_book(db: Database, Path(book_id): Path) -> impl IntoRespon ) AS "annotation_exists!: bool", ( SELECT - JSON_BUILD_OBJECT( + JSONB_BUILD_OBJECT( 'id', sources.id, 'name', sources.name ) diff --git a/src/views/genres.rs b/src/views/genres.rs index 87785f8..c5b23eb 100644 --- a/src/views/genres.rs +++ b/src/views/genres.rs @@ -39,7 +39,7 @@ pub async fn get_genres( genres.meta, ( SELECT - JSON_BUILD_OBJECT( + JSONB_BUILD_OBJECT( 'id', sources.id, 'name', sources.name ) @@ -76,7 +76,7 @@ pub async fn get_genre_metas(db: Database) -> impl IntoResponse { genres.meta, ( SELECT - JSON_BUILD_OBJECT( + JSONB_BUILD_OBJECT( 'id', sources.id, 'name', sources.name ) diff --git a/src/views/sequences.rs b/src/views/sequences.rs index f549354..4a840cd 100644 --- a/src/views/sequences.rs +++ b/src/views/sequences.rs @@ -215,8 +215,8 @@ async fn get_sequence_books( b.uploaded, ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', authors.id, 'first_name', authors.first_name, 'last_name', authors.last_name, @@ -232,8 +232,8 @@ async fn get_sequence_books( ) AS "authors!: Vec", ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', authors.id, 'first_name', authors.first_name, 'last_name', authors.last_name, diff --git a/src/views/translators.rs b/src/views/translators.rs index d2acd15..588772a 100644 --- a/src/views/translators.rs +++ b/src/views/translators.rs @@ -88,8 +88,8 @@ async fn get_translated_books( b.uploaded, ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', authors.id, 'first_name', authors.first_name, 'last_name', authors.last_name, @@ -105,8 +105,8 @@ async fn get_translated_books( ) AS "authors!: Vec", ( SELECT - JSON_AGG( - JSON_BUILD_OBJECT( + JSONB_AGG( + JSONB_BUILD_OBJECT( 'id', sequences.id, 'name', sequences.name )