This commit is contained in:
2024-12-26 01:28:32 +01:00
parent 3e8500e825
commit c58e10bfa0
29 changed files with 1622 additions and 865 deletions

View File

@@ -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<String>\",\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<Author>\",\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<Author>\",\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<String>",
"type_info": "TextArray"
},
{
"ordinal": 6,
"name": "uploaded",
"type_info": "Date"
},
{
"ordinal": 7,
"name": "authors!: Vec<Author>",
"type_info": "Jsonb"
},
{
"ordinal": 8,
"name": "translators!: Vec<Author>",
"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"
}

View File

@@ -1,6 +1,6 @@
{ {
"db_name": "PostgreSQL", "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 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 ", "query": "\n SELECT\n genres.id,\n genres.remote_id,\n genres.code,\n genres.description,\n genres.meta,\n (\n SELECT\n ROW(\n sources.id,\n sources.name\n )::source_type\n FROM sources\n WHERE sources.id = genres.source\n ) AS \"source!: Source\"\n FROM genres\n ORDER BY genres.id ASC\n ",
"describe": { "describe": {
"columns": [ "columns": [
{ {
@@ -31,7 +31,23 @@
{ {
"ordinal": 5, "ordinal": 5,
"name": "source!: Source", "name": "source!: Source",
"type_info": "Jsonb" "type_info": {
"Custom": {
"name": "source_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"name",
"Varchar"
]
]
}
}
}
} }
], ],
"parameters": { "parameters": {
@@ -46,5 +62,5 @@
null null
] ]
}, },
"hash": "763625de44f46e1183a1ca2760120ce0303b571ffbc4e5f544340b5134229940" "hash": "1f78b5cbdae5f9732e3637fcfd1605477bafc12a443900276c46df644a7f6d26"
} }

View File

@@ -0,0 +1,210 @@
{
"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<String>\",\n b.uploaded,\n (\n SELECT\n ARRAY_AGG(\n ROW(\n authors.id,\n authors.first_name,\n authors.last_name,\n authors.middle_name,\n EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )::author_type\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<Author>\",\n (\n SELECT\n ARRAY_AGG(\n ROW(\n authors.id,\n authors.first_name,\n authors.last_name,\n authors.middle_name,\n EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )::author_type\n )\n FROM translations\n JOIN authors ON authors.id = translations.author\n WHERE translations.book = b.id\n ) AS \"translators!: Vec<Author>\",\n (\n SELECT\n ARRAY_AGG(\n ROW(\n sequences.id,\n sequences.name\n )::sequence_type\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<Sequence>\",\n EXISTS(\n SELECT * FROM book_annotations WHERE book = b.id\n ) AS \"annotation_exists!: bool\",\n (\n SELECT\n ROW(\n sources.id,\n sources.name\n )::source_type\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<String>",
"type_info": "TextArray"
},
{
"ordinal": 6,
"name": "uploaded",
"type_info": "Date"
},
{
"ordinal": 7,
"name": "authors!: Vec<Author>",
"type_info": {
"Custom": {
"name": "author_type[]",
"kind": {
"Array": {
"Custom": {
"name": "author_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"first_name",
"Varchar"
],
[
"last_name",
"Varchar"
],
[
"middle_name",
"Varchar"
],
[
"annotation_exists",
"Bool"
]
]
}
}
}
}
}
}
},
{
"ordinal": 8,
"name": "translators!: Vec<Author>",
"type_info": {
"Custom": {
"name": "author_type[]",
"kind": {
"Array": {
"Custom": {
"name": "author_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"first_name",
"Varchar"
],
[
"last_name",
"Varchar"
],
[
"middle_name",
"Varchar"
],
[
"annotation_exists",
"Bool"
]
]
}
}
}
}
}
}
},
{
"ordinal": 9,
"name": "sequences!: Vec<Sequence>",
"type_info": {
"Custom": {
"name": "sequence_type[]",
"kind": {
"Array": {
"Custom": {
"name": "sequence_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"name",
"Varchar"
]
]
}
}
}
}
}
}
},
{
"ordinal": 10,
"name": "annotation_exists!: bool",
"type_info": "Bool"
},
{
"ordinal": 11,
"name": "source!: Source",
"type_info": {
"Custom": {
"name": "source_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"name",
"Varchar"
]
]
}
}
}
},
{
"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": "4fcb5676ff01cdeb824340375a2c96bd887d93d7cc6254ce5bead2ff3d7f3971"
}

View File

@@ -0,0 +1,132 @@
{
"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<String>\",\n b.uploaded,\n (\n SELECT\n ARRAY_AGG(\n ROW(\n authors.id,\n authors.first_name,\n authors.last_name,\n authors.middle_name,\n EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )::author_type\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<Author>\",\n (\n SELECT\n ARRAY_AGG(\n ROW(\n sequences.id,\n sequences.name\n )::sequence_type\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<Sequence>\",\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<String>",
"type_info": "TextArray"
},
{
"ordinal": 6,
"name": "uploaded",
"type_info": "Date"
},
{
"ordinal": 7,
"name": "authors!: Vec<Author>",
"type_info": {
"Custom": {
"name": "author_type[]",
"kind": {
"Array": {
"Custom": {
"name": "author_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"first_name",
"Varchar"
],
[
"last_name",
"Varchar"
],
[
"middle_name",
"Varchar"
],
[
"annotation_exists",
"Bool"
]
]
}
}
}
}
}
}
},
{
"ordinal": 8,
"name": "sequences!: Vec<Sequence>",
"type_info": {
"Custom": {
"name": "sequence_type[]",
"kind": {
"Array": {
"Custom": {
"name": "sequence_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"name",
"Varchar"
]
]
}
}
}
}
}
}
},
{
"ordinal": 9,
"name": "annotation_exists!: bool",
"type_info": "Bool"
}
],
"parameters": {
"Left": []
},
"nullable": [
false,
false,
false,
false,
false,
null,
false,
null,
null,
null
]
},
"hash": "50379dd90ab755cdbeba57ea4ca62863aa087c35b4afa30c51224fe11cb0a823"
}

View File

@@ -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<String>\",\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<Author>\",\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<Author>\",\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<Sequence>\",\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<Genre>\",\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<String>",
"type_info": "TextArray"
},
{
"ordinal": 6,
"name": "uploaded",
"type_info": "Date"
},
{
"ordinal": 7,
"name": "authors!: Vec<Author>",
"type_info": "Jsonb"
},
{
"ordinal": 8,
"name": "translators!: Vec<Author>",
"type_info": "Jsonb"
},
{
"ordinal": 9,
"name": "sequences!: Vec<Sequence>",
"type_info": "Jsonb"
},
{
"ordinal": 10,
"name": "genres!: Vec<Genre>",
"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"
}

View File

@@ -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<String>\",\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<Author>\",\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<Sequence>\",\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<String>",
"type_info": "TextArray"
},
{
"ordinal": 6,
"name": "uploaded",
"type_info": "Date"
},
{
"ordinal": 7,
"name": "authors!: Vec<Author>",
"type_info": "Jsonb"
},
{
"ordinal": 8,
"name": "sequences!: Vec<Sequence>",
"type_info": "Jsonb"
},
{
"ordinal": 9,
"name": "annotation_exists!: bool",
"type_info": "Bool"
}
],
"parameters": {
"Left": []
},
"nullable": [
false,
false,
false,
false,
false,
null,
false,
null,
null,
null
]
},
"hash": "6f91dfb52d18d080bcaf1dfbf7b7d4b6a6168cc33312d767798815d802962ff9"
}

View File

@@ -0,0 +1,277 @@
{
"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<String>\",\n b.uploaded,\n (\n SELECT\n ARRAY_AGG(\n ROW(\n authors.id,\n authors.first_name,\n authors.last_name,\n authors.middle_name,\n EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )::author_type\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<Author>\",\n (\n SELECT\n ARRAY_AGG(\n ROW(\n authors.id,\n authors.first_name,\n authors.last_name,\n authors.middle_name,\n EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )::author_type\n )\n FROM translations\n JOIN authors ON authors.id = translations.author\n WHERE translations.book = b.id\n ) AS \"translators!: Vec<Author>\",\n (\n SELECT\n ARRAY_AGG(\n ROW(\n sequences.id,\n sequences.name\n )::sequence_type\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<Sequence>\",\n (\n SELECT\n ARRAY_AGG(\n ROW(\n genres.id,\n ROW(\n sources.id,\n sources.name\n )::source_type,\n remote_id,\n genres.code,\n genres.description,\n genres.meta\n )::genre_type\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<Genre>\",\n EXISTS(\n SELECT * FROM book_annotations WHERE book = b.id\n ) AS \"annotation_exists!: bool\",\n (\n SELECT\n ROW(\n sources.id,\n sources.name\n )::source_type\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<String>",
"type_info": "TextArray"
},
{
"ordinal": 6,
"name": "uploaded",
"type_info": "Date"
},
{
"ordinal": 7,
"name": "authors!: Vec<Author>",
"type_info": {
"Custom": {
"name": "author_type[]",
"kind": {
"Array": {
"Custom": {
"name": "author_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"first_name",
"Varchar"
],
[
"last_name",
"Varchar"
],
[
"middle_name",
"Varchar"
],
[
"annotation_exists",
"Bool"
]
]
}
}
}
}
}
}
},
{
"ordinal": 8,
"name": "translators!: Vec<Author>",
"type_info": {
"Custom": {
"name": "author_type[]",
"kind": {
"Array": {
"Custom": {
"name": "author_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"first_name",
"Varchar"
],
[
"last_name",
"Varchar"
],
[
"middle_name",
"Varchar"
],
[
"annotation_exists",
"Bool"
]
]
}
}
}
}
}
}
},
{
"ordinal": 9,
"name": "sequences!: Vec<Sequence>",
"type_info": {
"Custom": {
"name": "sequence_type[]",
"kind": {
"Array": {
"Custom": {
"name": "sequence_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"name",
"Varchar"
]
]
}
}
}
}
}
}
},
{
"ordinal": 10,
"name": "genres!: Vec<Genre>",
"type_info": {
"Custom": {
"name": "genre_type[]",
"kind": {
"Array": {
"Custom": {
"name": "genre_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"source",
{
"Custom": {
"name": "source_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"name",
"Varchar"
]
]
}
}
}
],
[
"remote_id",
"Int4"
],
[
"code",
"Varchar"
],
[
"description",
"Varchar"
],
[
"meta",
"Varchar"
]
]
}
}
}
}
}
}
},
{
"ordinal": 11,
"name": "annotation_exists!: bool",
"type_info": "Bool"
},
{
"ordinal": 12,
"name": "source!: Source",
"type_info": {
"Custom": {
"name": "source_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"name",
"Varchar"
]
]
}
}
}
},
{
"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": "71a1b03481c1642c963b1641da8dbcc308fee8ca82b5800746f1568fb358bc37"
}

View File

@@ -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<String>\",\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<Author>\",\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<Author>\",\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<Sequence>\",\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<String>",
"type_info": "TextArray"
},
{
"ordinal": 6,
"name": "uploaded",
"type_info": "Date"
},
{
"ordinal": 7,
"name": "authors!: Vec<Author>",
"type_info": "Jsonb"
},
{
"ordinal": 8,
"name": "translators!: Vec<Author>",
"type_info": "Jsonb"
},
{
"ordinal": 9,
"name": "sequences!: Vec<Sequence>",
"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"
}

View File

@@ -1,79 +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<String>\",\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<Author>\",\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<Sequence>\",\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<String>",
"type_info": "TextArray"
},
{
"ordinal": 6,
"name": "uploaded",
"type_info": "Date"
},
{
"ordinal": 7,
"name": "translators!: Vec<Author>",
"type_info": "Jsonb"
},
{
"ordinal": 8,
"name": "sequences!: Vec<Sequence>",
"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"
}

View File

@@ -1,6 +1,6 @@
{ {
"db_name": "PostgreSQL", "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 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 ", "query": "\n SELECT\n genres.id,\n genres.remote_id,\n genres.code,\n genres.description,\n genres.meta,\n (\n SELECT\n ROW(\n sources.id,\n sources.name\n )::source_type\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": { "describe": {
"columns": [ "columns": [
{ {
@@ -31,7 +31,23 @@
{ {
"ordinal": 5, "ordinal": 5,
"name": "source!: Source", "name": "source!: Source",
"type_info": "Jsonb" "type_info": {
"Custom": {
"name": "source_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"name",
"Varchar"
]
]
}
}
}
} }
], ],
"parameters": { "parameters": {
@@ -50,5 +66,5 @@
null null
] ]
}, },
"hash": "868081a73c2ee8e44db3d19d82afed39949d5310dfccdea2bbda1086f8ff9120" "hash": "a22bfa2e92bf4a3b0710388c6c5bbfa50f24864b183bb304d35cea18babd8ce3"
} }

View File

@@ -0,0 +1,137 @@
{
"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<String>\",\n b.uploaded,\n (\n SELECT\n ARRAY_AGG(\n ROW(\n authors.id,\n authors.first_name,\n authors.last_name,\n authors.middle_name,\n EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )::author_type\n )\n FROM translations\n JOIN authors ON authors.id = translations.author\n WHERE translations.book = b.id\n ) AS \"translators!: Vec<Author>\",\n (\n SELECT\n ARRAY_AGG(\n ROW(\n sequences.id,\n sequences.name\n )::sequence_type\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<Sequence>\",\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<String>",
"type_info": "TextArray"
},
{
"ordinal": 6,
"name": "uploaded",
"type_info": "Date"
},
{
"ordinal": 7,
"name": "translators!: Vec<Author>",
"type_info": {
"Custom": {
"name": "author_type[]",
"kind": {
"Array": {
"Custom": {
"name": "author_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"first_name",
"Varchar"
],
[
"last_name",
"Varchar"
],
[
"middle_name",
"Varchar"
],
[
"annotation_exists",
"Bool"
]
]
}
}
}
}
}
}
},
{
"ordinal": 8,
"name": "sequences!: Vec<Sequence>",
"type_info": {
"Custom": {
"name": "sequence_type[]",
"kind": {
"Array": {
"Custom": {
"name": "sequence_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"name",
"Varchar"
]
]
}
}
}
}
}
}
},
{
"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": "bc0b43e31b7a519ca33aaf431958dbefffbb9ee0acfb8de275eaec3ced2e38ed"
}

View File

@@ -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<String>\",\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<Author>\",\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<Author>\",\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<Sequence>\",\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<String>",
"type_info": "TextArray"
},
{
"ordinal": 6,
"name": "uploaded",
"type_info": "Date"
},
{
"ordinal": 7,
"name": "authors!: Vec<Author>",
"type_info": "Jsonb"
},
{
"ordinal": 8,
"name": "translators!: Vec<Author>",
"type_info": "Jsonb"
},
{
"ordinal": 9,
"name": "sequences!: Vec<Sequence>",
"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"
}

View File

@@ -0,0 +1,155 @@
{
"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<String>\",\n b.uploaded,\n (\n SELECT\n ARRAY_AGG(\n ROW(\n authors.id,\n authors.first_name,\n authors.last_name,\n authors.middle_name,\n EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )::author_type\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<Author>\",\n (\n SELECT\n ARRAY_AGG(\n ROW(\n authors.id,\n authors.first_name,\n authors.last_name,\n authors.middle_name,\n EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )::author_type\n )\n FROM translations\n JOIN authors ON authors.id = translations.author\n WHERE translations.book = b.id\n ) AS \"translators!: Vec<Author>\",\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<String>",
"type_info": "TextArray"
},
{
"ordinal": 6,
"name": "uploaded",
"type_info": "Date"
},
{
"ordinal": 7,
"name": "authors!: Vec<Author>",
"type_info": {
"Custom": {
"name": "author_type[]",
"kind": {
"Array": {
"Custom": {
"name": "author_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"first_name",
"Varchar"
],
[
"last_name",
"Varchar"
],
[
"middle_name",
"Varchar"
],
[
"annotation_exists",
"Bool"
]
]
}
}
}
}
}
}
},
{
"ordinal": 8,
"name": "translators!: Vec<Author>",
"type_info": {
"Custom": {
"name": "author_type[]",
"kind": {
"Array": {
"Custom": {
"name": "author_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"first_name",
"Varchar"
],
[
"last_name",
"Varchar"
],
[
"middle_name",
"Varchar"
],
[
"annotation_exists",
"Bool"
]
]
}
}
}
}
}
}
},
{
"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": "dde0ea9311fc1e4b0e300b9c9051282e1899b0d9c15567c9a15d0e39484cbb37"
}

View File

@@ -0,0 +1,175 @@
{
"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<String>\",\n b.uploaded,\n (\n SELECT\n ARRAY_AGG(\n ROW(\n authors.id,\n authors.first_name,\n authors.last_name,\n authors.middle_name,\n EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )::author_type\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<Author>\",\n (\n SELECT\n ARRAY_AGG(\n ROW(\n authors.id,\n authors.first_name,\n authors.last_name,\n authors.middle_name,\n EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )::author_type\n )\n FROM translations\n JOIN authors ON authors.id = translations.author\n WHERE translations.book = b.id\n ) AS \"translators!: Vec<Author>\",\n (\n SELECT\n ARRAY_AGG(\n ROW(\n sequences.id,\n sequences.name\n )::sequence_type\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<Sequence>\",\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<String>",
"type_info": "TextArray"
},
{
"ordinal": 6,
"name": "uploaded",
"type_info": "Date"
},
{
"ordinal": 7,
"name": "authors!: Vec<Author>",
"type_info": {
"Custom": {
"name": "author_type[]",
"kind": {
"Array": {
"Custom": {
"name": "author_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"first_name",
"Varchar"
],
[
"last_name",
"Varchar"
],
[
"middle_name",
"Varchar"
],
[
"annotation_exists",
"Bool"
]
]
}
}
}
}
}
}
},
{
"ordinal": 8,
"name": "translators!: Vec<Author>",
"type_info": {
"Custom": {
"name": "author_type[]",
"kind": {
"Array": {
"Custom": {
"name": "author_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"first_name",
"Varchar"
],
[
"last_name",
"Varchar"
],
[
"middle_name",
"Varchar"
],
[
"annotation_exists",
"Bool"
]
]
}
}
}
}
}
}
},
{
"ordinal": 9,
"name": "sequences!: Vec<Sequence>",
"type_info": {
"Custom": {
"name": "sequence_type[]",
"kind": {
"Array": {
"Custom": {
"name": "sequence_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"name",
"Varchar"
]
]
}
}
}
}
}
}
},
{
"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": "df1babb391f678c6c4e79a382f43b248c47c57a78620a7147b1f42a886154d8d"
}

View File

@@ -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<String>\",\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<Author>\",\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<Author>\",\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<Sequence>\",\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<Genre>\",\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<String>",
"type_info": "TextArray"
},
{
"ordinal": 6,
"name": "uploaded",
"type_info": "Date"
},
{
"ordinal": 7,
"name": "authors!: Vec<Author>",
"type_info": "Jsonb"
},
{
"ordinal": 8,
"name": "translators!: Vec<Author>",
"type_info": "Jsonb"
},
{
"ordinal": 9,
"name": "sequences!: Vec<Sequence>",
"type_info": "Jsonb"
},
{
"ordinal": 10,
"name": "genres!: Vec<Genre>",
"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"
}

View File

@@ -0,0 +1,276 @@
{
"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<String>\",\n b.uploaded,\n (\n SELECT\n ARRAY_AGG(\n ROW(\n authors.id,\n authors.first_name,\n authors.last_name,\n authors.middle_name,\n EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )::author_type\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<Author>\",\n (\n SELECT\n ARRAY_AGG(\n ROW(\n authors.id,\n authors.first_name,\n authors.last_name,\n authors.middle_name,\n EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )::author_type\n )\n FROM translations\n JOIN authors ON authors.id = translations.author\n WHERE translations.book = b.id\n ) AS \"translators!: Vec<Author>\",\n (\n SELECT\n ARRAY_AGG(\n ROW(\n sequences.id,\n sequences.name\n )::sequence_type\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<Sequence>\",\n (\n SELECT\n ARRAY_AGG(\n ROW(\n genres.id,\n ROW(\n sources.id,\n sources.name\n )::source_type,\n genres.remote_id,\n genres.code,\n genres.description,\n genres.meta\n )::genre_type\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<Genre>\",\n EXISTS(\n SELECT * FROM book_annotations WHERE book = b.id\n ) AS \"annotation_exists!: bool\",\n (\n SELECT\n ROW(\n sources.id,\n sources.name\n )::source_type\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<String>",
"type_info": "TextArray"
},
{
"ordinal": 6,
"name": "uploaded",
"type_info": "Date"
},
{
"ordinal": 7,
"name": "authors!: Vec<Author>",
"type_info": {
"Custom": {
"name": "author_type[]",
"kind": {
"Array": {
"Custom": {
"name": "author_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"first_name",
"Varchar"
],
[
"last_name",
"Varchar"
],
[
"middle_name",
"Varchar"
],
[
"annotation_exists",
"Bool"
]
]
}
}
}
}
}
}
},
{
"ordinal": 8,
"name": "translators!: Vec<Author>",
"type_info": {
"Custom": {
"name": "author_type[]",
"kind": {
"Array": {
"Custom": {
"name": "author_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"first_name",
"Varchar"
],
[
"last_name",
"Varchar"
],
[
"middle_name",
"Varchar"
],
[
"annotation_exists",
"Bool"
]
]
}
}
}
}
}
}
},
{
"ordinal": 9,
"name": "sequences!: Vec<Sequence>",
"type_info": {
"Custom": {
"name": "sequence_type[]",
"kind": {
"Array": {
"Custom": {
"name": "sequence_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"name",
"Varchar"
]
]
}
}
}
}
}
}
},
{
"ordinal": 10,
"name": "genres!: Vec<Genre>",
"type_info": {
"Custom": {
"name": "genre_type[]",
"kind": {
"Array": {
"Custom": {
"name": "genre_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"source",
{
"Custom": {
"name": "source_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"name",
"Varchar"
]
]
}
}
}
],
[
"remote_id",
"Int4"
],
[
"code",
"Varchar"
],
[
"description",
"Varchar"
],
[
"meta",
"Varchar"
]
]
}
}
}
}
}
}
},
{
"ordinal": 11,
"name": "annotation_exists!: bool",
"type_info": "Bool"
},
{
"ordinal": 12,
"name": "source!: Source",
"type_info": {
"Custom": {
"name": "source_type",
"kind": {
"Composite": [
[
"id",
"Int4"
],
[
"name",
"Varchar"
]
]
}
}
}
},
{
"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": "ff5b8a130876c7a3821814fb7038ce846f80be9ce07cb655e3b8c7539b084646"
}

1
Cargo.lock generated
View File

@@ -256,6 +256,7 @@ dependencies = [
"sentry", "sentry",
"sentry-tracing", "sentry-tracing",
"serde", "serde",
"serde_json",
"sqlx", "sqlx",
"tokio", "tokio",
"tower-http 0.6.2", "tower-http 0.6.2",

View File

@@ -18,6 +18,7 @@ axum = { version = "0.7.9", features = ["json"] }
axum-extra = { version ="0.9.6", features = ["query"] } axum-extra = { version ="0.9.6", features = ["query"] }
axum-prometheus = "0.7.0" axum-prometheus = "0.7.0"
serde = { version = "1.0.216", features = ["derive"] } serde = { version = "1.0.216", features = ["derive"] }
serde_json = { version = "1.0.134", features = ["raw_value"] }
sentry = { version = "0.35.0", features = ["debug-images"] } sentry = { version = "0.35.0", features = ["debug-images"] }

View File

@@ -5,6 +5,7 @@ use super::date::naive_date_serializer;
use super::sequence::Sequence; use super::sequence::Sequence;
#[derive(sqlx::FromRow, sqlx::Type, Serialize)] #[derive(sqlx::FromRow, sqlx::Type, Serialize)]
#[sqlx(type_name = "author_type")]
pub struct Author { pub struct Author {
pub id: i32, pub id: i32,
pub first_name: String, pub first_name: String,
@@ -23,7 +24,7 @@ pub struct AuthorBook {
pub available_types: Vec<String>, pub available_types: Vec<String>,
#[serde(serialize_with = "naive_date_serializer::serialize")] #[serde(serialize_with = "naive_date_serializer::serialize")]
pub uploaded: NaiveDate, pub uploaded: NaiveDate,
pub translators: sqlx::types::Json<Vec<Author>>, pub translators: Vec<Author>,
pub sequences: sqlx::types::Json<Vec<Sequence>>, pub sequences: Vec<Sequence>,
pub annotation_exists: bool, pub annotation_exists: bool,
} }

View File

@@ -81,8 +81,8 @@ pub struct Book {
pub available_types: Vec<String>, pub available_types: Vec<String>,
#[serde(serialize_with = "naive_date_serializer::serialize")] #[serde(serialize_with = "naive_date_serializer::serialize")]
pub uploaded: NaiveDate, pub uploaded: NaiveDate,
pub authors: sqlx::types::Json<Vec<Author>>, pub authors: Vec<Author>,
pub translators: sqlx::types::Json<Vec<Author>>, pub translators: Vec<Author>,
pub sequences: sqlx::types::Json<Vec<Sequence>>, pub sequences: Vec<Sequence>,
pub annotation_exists: bool, pub annotation_exists: bool,
} }

View File

@@ -3,6 +3,7 @@ use serde::{Deserialize, Serialize};
use super::source::Source; use super::source::Source;
#[derive(sqlx::FromRow, sqlx::Type, Serialize)] #[derive(sqlx::FromRow, sqlx::Type, Serialize)]
#[sqlx(type_name = "genre_type")]
pub struct Genre { pub struct Genre {
pub id: i32, pub id: i32,
pub source: Source, pub source: Source,

View File

@@ -5,6 +5,7 @@ use super::author::Author;
use super::date::naive_date_serializer; use super::date::naive_date_serializer;
#[derive(sqlx::FromRow, sqlx::Type, Serialize)] #[derive(sqlx::FromRow, sqlx::Type, Serialize)]
#[sqlx(type_name = "sequence_type")]
pub struct Sequence { pub struct Sequence {
pub id: i32, pub id: i32,
pub name: String, pub name: String,
@@ -20,8 +21,8 @@ pub struct SequenceBook {
pub available_types: Vec<String>, pub available_types: Vec<String>,
#[serde(serialize_with = "naive_date_serializer::serialize")] #[serde(serialize_with = "naive_date_serializer::serialize")]
pub uploaded: NaiveDate, pub uploaded: NaiveDate,
pub authors: sqlx::types::Json<Vec<Author>>, pub authors: Vec<Author>,
pub translators: sqlx::types::Json<Vec<Author>>, pub translators: Vec<Author>,
pub annotation_exists: bool, pub annotation_exists: bool,
pub position: i32, pub position: i32,
} }

View File

@@ -1,6 +1,7 @@
use serde::Serialize; use serde::Serialize;
#[derive(sqlx::FromRow, sqlx::Type, Serialize)] #[derive(sqlx::FromRow, sqlx::Type, Serialize)]
#[sqlx(type_name = "source_type")]
pub struct Source { pub struct Source {
pub id: i32, pub id: i32,
pub name: String, pub name: String,

View File

@@ -15,7 +15,7 @@ pub struct TranslatorBook {
pub available_types: Vec<String>, pub available_types: Vec<String>,
#[serde(serialize_with = "naive_date_serializer::serialize")] #[serde(serialize_with = "naive_date_serializer::serialize")]
pub uploaded: NaiveDate, pub uploaded: NaiveDate,
pub authors: sqlx::types::Json<Vec<Author>>, pub authors: Vec<Author>,
pub sequences: sqlx::types::Json<Vec<Sequence>>, pub sequences: Vec<Sequence>,
pub annotation_exists: bool, pub annotation_exists: bool,
} }

View File

@@ -216,16 +216,16 @@ async fn get_author_books(
b.uploaded, b.uploaded,
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', authors.id, authors.id,
'first_name', authors.first_name, authors.first_name,
'last_name', authors.last_name, authors.last_name,
'middle_name', authors.middle_name, authors.middle_name,
'annotation_exists', EXISTS( EXISTS(
SELECT * FROM author_annotations WHERE author = authors.id SELECT * FROM author_annotations WHERE author = authors.id
) )
) )::author_type
) )
FROM translations FROM translations
JOIN authors ON authors.id = translations.author JOIN authors ON authors.id = translations.author
@@ -233,11 +233,11 @@ async fn get_author_books(
) AS "translators!: Vec<Author>", ) AS "translators!: Vec<Author>",
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', sequences.id, sequences.id,
'name', sequences.name sequences.name
) )::sequence_type
) )
FROM book_sequences FROM book_sequences
JOIN sequences ON sequences.id = book_sequences.sequence JOIN sequences ON sequences.id = book_sequences.sequence

View File

@@ -62,16 +62,16 @@ pub async fn get_books(
b.uploaded, b.uploaded,
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', authors.id, authors.id,
'first_name', authors.first_name, authors.first_name,
'last_name', authors.last_name, authors.last_name,
'middle_name', authors.middle_name, authors.middle_name,
'annotation_exists', EXISTS( EXISTS(
SELECT * FROM author_annotations WHERE author = authors.id SELECT * FROM author_annotations WHERE author = authors.id
) )
) )::author_type
) )
FROM book_authors FROM book_authors
JOIN authors ON authors.id = book_authors.author JOIN authors ON authors.id = book_authors.author
@@ -79,16 +79,16 @@ pub async fn get_books(
) AS "authors!: Vec<Author>", ) AS "authors!: Vec<Author>",
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', authors.id, authors.id,
'first_name', authors.first_name, authors.first_name,
'last_name', authors.last_name, authors.last_name,
'middle_name', authors.middle_name, authors.middle_name,
'annotation_exists', EXISTS( EXISTS(
SELECT * FROM author_annotations WHERE author = authors.id SELECT * FROM author_annotations WHERE author = authors.id
) )
) )::author_type
) )
FROM translations FROM translations
JOIN authors ON authors.id = translations.author JOIN authors ON authors.id = translations.author
@@ -96,11 +96,11 @@ pub async fn get_books(
) AS "translators!: Vec<Author>", ) AS "translators!: Vec<Author>",
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', sequences.id, sequences.id,
'name', sequences.name sequences.name
) )::sequence_type
) )
FROM book_sequences FROM book_sequences
JOIN sequences ON sequences.id = book_sequences.sequence JOIN sequences ON sequences.id = book_sequences.sequence
@@ -111,10 +111,10 @@ pub async fn get_books(
) AS "annotation_exists!: bool", ) AS "annotation_exists!: bool",
( (
SELECT SELECT
JSONB_BUILD_OBJECT( ROW(
'id', sources.id, sources.id,
'name', sources.name sources.name
) )::source_type
FROM sources FROM sources
WHERE sources.id = b.source WHERE sources.id = b.source
) AS "source!: Source", ) AS "source!: Source",
@@ -245,16 +245,16 @@ pub async fn get_random_book(
b.uploaded, b.uploaded,
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', authors.id, authors.id,
'first_name', authors.first_name, authors.first_name,
'last_name', authors.last_name, authors.last_name,
'middle_name', authors.middle_name, authors.middle_name,
'annotation_exists', EXISTS( EXISTS(
SELECT * FROM author_annotations WHERE author = authors.id SELECT * FROM author_annotations WHERE author = authors.id
) )
) )::author_type
) )
FROM book_authors FROM book_authors
JOIN authors ON authors.id = book_authors.author JOIN authors ON authors.id = book_authors.author
@@ -262,16 +262,16 @@ pub async fn get_random_book(
) AS "authors!: Vec<Author>", ) AS "authors!: Vec<Author>",
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', authors.id, authors.id,
'first_name', authors.first_name, authors.first_name,
'last_name', authors.last_name, authors.last_name,
'middle_name', authors.middle_name, authors.middle_name,
'annotation_exists', EXISTS( EXISTS(
SELECT * FROM author_annotations WHERE author = authors.id SELECT * FROM author_annotations WHERE author = authors.id
) )
) )::author_type
) )
FROM translations FROM translations
JOIN authors ON authors.id = translations.author JOIN authors ON authors.id = translations.author
@@ -279,11 +279,11 @@ pub async fn get_random_book(
) AS "translators!: Vec<Author>", ) AS "translators!: Vec<Author>",
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', sequences.id, sequences.id,
'name', sequences.name sequences.name
) )::sequence_type
) )
FROM book_sequences FROM book_sequences
JOIN sequences ON sequences.id = book_sequences.sequence JOIN sequences ON sequences.id = book_sequences.sequence
@@ -291,17 +291,18 @@ pub async fn get_random_book(
) AS "sequences!: Vec<Sequence>", ) AS "sequences!: Vec<Sequence>",
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', genres.id, genres.id,
'code', genres.code, ROW(
'description', genres.description, sources.id,
'meta', genres.meta, sources.name
'source', JSONB_BUILD_OBJECT( )::source_type,
'id', sources.id, genres.remote_id,
'name', sources.name genres.code,
) genres.description,
) genres.meta
)::genre_type
) )
FROM book_genres FROM book_genres
JOIN genres ON genres.id = book_genres.genre JOIN genres ON genres.id = book_genres.genre
@@ -313,10 +314,10 @@ pub async fn get_random_book(
) AS "annotation_exists!: bool", ) AS "annotation_exists!: bool",
( (
SELECT SELECT
JSONB_BUILD_OBJECT( ROW(
'id', sources.id, sources.id,
'name', sources.name sources.name
) )::source_type
FROM sources FROM sources
WHERE sources.id = b.source WHERE sources.id = b.source
) AS "source!: Source", ) AS "source!: Source",
@@ -353,16 +354,16 @@ pub async fn get_remote_book(
b.uploaded, b.uploaded,
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', authors.id, authors.id,
'first_name', authors.first_name, authors.first_name,
'last_name', authors.last_name, authors.last_name,
'middle_name', authors.middle_name, authors.middle_name,
'annotation_exists', EXISTS( EXISTS(
SELECT * FROM author_annotations WHERE author = authors.id SELECT * FROM author_annotations WHERE author = authors.id
) )
) )::author_type
) )
FROM book_authors FROM book_authors
JOIN authors ON authors.id = book_authors.author JOIN authors ON authors.id = book_authors.author
@@ -370,16 +371,16 @@ pub async fn get_remote_book(
) AS "authors!: Vec<Author>", ) AS "authors!: Vec<Author>",
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', authors.id, authors.id,
'first_name', authors.first_name, authors.first_name,
'last_name', authors.last_name, authors.last_name,
'middle_name', authors.middle_name, authors.middle_name,
'annotation_exists', EXISTS( EXISTS(
SELECT * FROM author_annotations WHERE author = authors.id SELECT * FROM author_annotations WHERE author = authors.id
) )
) )::author_type
) )
FROM translations FROM translations
JOIN authors ON authors.id = translations.author JOIN authors ON authors.id = translations.author
@@ -387,11 +388,11 @@ pub async fn get_remote_book(
) AS "translators!: Vec<Author>", ) AS "translators!: Vec<Author>",
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', sequences.id, sequences.id,
'name', sequences.name sequences.name
) )::sequence_type
) )
FROM book_sequences FROM book_sequences
JOIN sequences ON sequences.id = book_sequences.sequence JOIN sequences ON sequences.id = book_sequences.sequence
@@ -399,17 +400,18 @@ pub async fn get_remote_book(
) AS "sequences!: Vec<Sequence>", ) AS "sequences!: Vec<Sequence>",
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', genres.id, genres.id,
'code', genres.code, ROW(
'description', genres.description, sources.id,
'meta', genres.meta, sources.name
'source', JSONB_BUILD_OBJECT( )::source_type,
'id', sources.id, remote_id,
'name', sources.name genres.code,
) genres.description,
) genres.meta
)::genre_type
) )
FROM book_genres FROM book_genres
JOIN genres ON genres.id = book_genres.genre JOIN genres ON genres.id = book_genres.genre
@@ -421,10 +423,10 @@ pub async fn get_remote_book(
) AS "annotation_exists!: bool", ) AS "annotation_exists!: bool",
( (
SELECT SELECT
JSONB_BUILD_OBJECT( ROW(
'id', sources.id, sources.id,
'name', sources.name sources.name
) )::source_type
FROM sources FROM sources
WHERE sources.id = b.source WHERE sources.id = b.source
) AS "source!: Source", ) AS "source!: Source",
@@ -491,16 +493,16 @@ pub async fn search_books(
b.uploaded, b.uploaded,
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', authors.id, authors.id,
'first_name', authors.first_name, authors.first_name,
'last_name', authors.last_name, authors.last_name,
'middle_name', authors.middle_name, authors.middle_name,
'annotation_exists', EXISTS( EXISTS(
SELECT * FROM author_annotations WHERE author = authors.id SELECT * FROM author_annotations WHERE author = authors.id
) )
) )::author_type
) )
FROM book_authors FROM book_authors
JOIN authors ON authors.id = book_authors.author JOIN authors ON authors.id = book_authors.author
@@ -508,16 +510,16 @@ pub async fn search_books(
) AS "authors!: Vec<Author>", ) AS "authors!: Vec<Author>",
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', authors.id, authors.id,
'first_name', authors.first_name, authors.first_name,
'last_name', authors.last_name, authors.last_name,
'middle_name', authors.middle_name, authors.middle_name,
'annotation_exists', EXISTS( EXISTS(
SELECT * FROM author_annotations WHERE author = authors.id SELECT * FROM author_annotations WHERE author = authors.id
) )
) )::author_type
) )
FROM translations FROM translations
JOIN authors ON authors.id = translations.author JOIN authors ON authors.id = translations.author
@@ -525,11 +527,11 @@ pub async fn search_books(
) AS "translators!: Vec<Author>", ) AS "translators!: Vec<Author>",
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', sequences.id, sequences.id,
'name', sequences.name sequences.name
) )::sequence_type
) )
FROM book_sequences FROM book_sequences
JOIN sequences ON sequences.id = book_sequences.sequence JOIN sequences ON sequences.id = book_sequences.sequence
@@ -573,16 +575,16 @@ pub async fn get_book(db: Database, Path(book_id): Path<i32>) -> impl IntoRespon
b.uploaded, b.uploaded,
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', authors.id, authors.id,
'first_name', authors.first_name, authors.first_name,
'last_name', authors.last_name, authors.last_name,
'middle_name', authors.middle_name, authors.middle_name,
'annotation_exists', EXISTS( EXISTS(
SELECT * FROM author_annotations WHERE author = authors.id SELECT * FROM author_annotations WHERE author = authors.id
) )
) )::author_type
) )
FROM book_authors FROM book_authors
JOIN authors ON authors.id = book_authors.author JOIN authors ON authors.id = book_authors.author
@@ -590,16 +592,16 @@ pub async fn get_book(db: Database, Path(book_id): Path<i32>) -> impl IntoRespon
) AS "authors!: Vec<Author>", ) AS "authors!: Vec<Author>",
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', authors.id, authors.id,
'first_name', authors.first_name, authors.first_name,
'last_name', authors.last_name, authors.last_name,
'middle_name', authors.middle_name, authors.middle_name,
'annotation_exists', EXISTS( EXISTS(
SELECT * FROM author_annotations WHERE author = authors.id SELECT * FROM author_annotations WHERE author = authors.id
) )
) )::author_type
) )
FROM translations FROM translations
JOIN authors ON authors.id = translations.author JOIN authors ON authors.id = translations.author
@@ -607,11 +609,11 @@ pub async fn get_book(db: Database, Path(book_id): Path<i32>) -> impl IntoRespon
) AS "translators!: Vec<Author>", ) AS "translators!: Vec<Author>",
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', sequences.id, sequences.id,
'name', sequences.name sequences.name
) )::sequence_type
) )
FROM book_sequences FROM book_sequences
JOIN sequences ON sequences.id = book_sequences.sequence JOIN sequences ON sequences.id = book_sequences.sequence
@@ -619,17 +621,18 @@ pub async fn get_book(db: Database, Path(book_id): Path<i32>) -> impl IntoRespon
) AS "sequences!: Vec<Sequence>", ) AS "sequences!: Vec<Sequence>",
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', genres.id, genres.id,
'code', genres.code, ROW(
'description', genres.description, sources.id,
'meta', genres.meta, sources.name
'source', JSONB_BUILD_OBJECT( )::source_type,
'id', sources.id, genres.remote_id,
'name', sources.name genres.code,
) genres.description,
) genres.meta
)::genre_type
) )
FROM book_genres FROM book_genres
JOIN genres ON genres.id = book_genres.genre JOIN genres ON genres.id = book_genres.genre
@@ -641,10 +644,10 @@ pub async fn get_book(db: Database, Path(book_id): Path<i32>) -> impl IntoRespon
) AS "annotation_exists!: bool", ) AS "annotation_exists!: bool",
( (
SELECT SELECT
JSONB_BUILD_OBJECT( ROW(
'id', sources.id, sources.id,
'name', sources.name sources.name
) )::source_type
FROM sources FROM sources
WHERE sources.id = b.source WHERE sources.id = b.source
) AS "source!: Source", ) AS "source!: Source",

View File

@@ -39,10 +39,10 @@ pub async fn get_genres(
genres.meta, genres.meta,
( (
SELECT SELECT
JSONB_BUILD_OBJECT( ROW(
'id', sources.id, sources.id,
'name', sources.name sources.name
) )::source_type
FROM sources FROM sources
WHERE sources.id = genres.source WHERE sources.id = genres.source
) AS "source!: Source" ) AS "source!: Source"
@@ -76,10 +76,10 @@ pub async fn get_genre_metas(db: Database) -> impl IntoResponse {
genres.meta, genres.meta,
( (
SELECT SELECT
JSONB_BUILD_OBJECT( ROW(
'id', sources.id, sources.id,
'name', sources.name sources.name
) )::source_type
FROM sources FROM sources
WHERE sources.id = genres.source WHERE sources.id = genres.source
) AS "source!: Source" ) AS "source!: Source"

View File

@@ -215,16 +215,16 @@ async fn get_sequence_books(
b.uploaded, b.uploaded,
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', authors.id, authors.id,
'first_name', authors.first_name, authors.first_name,
'last_name', authors.last_name, authors.last_name,
'middle_name', authors.middle_name, authors.middle_name,
'annotation_exists', EXISTS( EXISTS(
SELECT * FROM author_annotations WHERE author = authors.id SELECT * FROM author_annotations WHERE author = authors.id
) )
) )::author_type
) )
FROM book_authors FROM book_authors
JOIN authors ON authors.id = book_authors.author JOIN authors ON authors.id = book_authors.author
@@ -232,16 +232,16 @@ async fn get_sequence_books(
) AS "authors!: Vec<Author>", ) AS "authors!: Vec<Author>",
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', authors.id, authors.id,
'first_name', authors.first_name, authors.first_name,
'last_name', authors.last_name, authors.last_name,
'middle_name', authors.middle_name, authors.middle_name,
'annotation_exists', EXISTS( EXISTS(
SELECT * FROM author_annotations WHERE author = authors.id SELECT * FROM author_annotations WHERE author = authors.id
) )
) )::author_type
) )
FROM translations FROM translations
JOIN authors ON authors.id = translations.author JOIN authors ON authors.id = translations.author

View File

@@ -88,16 +88,16 @@ async fn get_translated_books(
b.uploaded, b.uploaded,
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', authors.id, authors.id,
'first_name', authors.first_name, authors.first_name,
'last_name', authors.last_name, authors.last_name,
'middle_name', authors.middle_name, authors.middle_name,
'annotation_exists', EXISTS( EXISTS(
SELECT * FROM author_annotations WHERE author = authors.id SELECT * FROM author_annotations WHERE author = authors.id
) )
) )::author_type
) )
FROM book_authors FROM book_authors
JOIN authors ON authors.id = book_authors.author JOIN authors ON authors.id = book_authors.author
@@ -105,11 +105,11 @@ async fn get_translated_books(
) AS "authors!: Vec<Author>", ) AS "authors!: Vec<Author>",
( (
SELECT SELECT
JSONB_AGG( ARRAY_AGG(
JSONB_BUILD_OBJECT( ROW(
'id', sequences.id, sequences.id,
'name', sequences.name sequences.name
) )::sequence_type
) )
FROM book_sequences FROM book_sequences
JOIN sequences ON sequences.id = book_sequences.sequence JOIN sequences ON sequences.id = book_sequences.sequence