You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
synctv/.sqlx/query-c48ec8c1f7bfd8dc0c1a0...

193 lines
6.4 KiB
JSON

{
"db_name": "PostgreSQL",
"query": "\n SELECT u.id AS \"id!: UserId\",\n u.username AS \"username!\",\n u.role AS \"role!: crate::models::UserRole\",\n u.avatar_file_reference_id,\n CASE\n WHEN active_ban.user_id IS NULL THEN 1::SMALLINT\n ELSE 2::SMALLINT\n END AS \"status!: crate::models::UserStatus\",\n (active_ban.user_id IS NOT NULL) AS \"is_banned!\",\n active_ban.starts_at AS \"banned_at?\",\n active_ban.banned_by AS \"banned_by?: UserId\",\n active_ban.reason AS banned_reason,\n u.signup_method AS \"signup_method!: crate::models::SignupMethod\",\n u.created_at AS \"created_at!\",\n u.updated_at AS \"updated_at!\",\n u.version AS \"version!\",\n u.deleted_at,\n crs.updated_at AS \"read_at!\"\n FROM room_members rm\n JOIN users u ON u.id = rm.user_id AND u.deleted_at IS NULL\n LEFT JOIN LATERAL (\n SELECT ub.user_id,\n ub.starts_at,\n ub.banned_by,\n ub.reason\n FROM user_bans ub\n WHERE ub.user_id = u.id\n AND ub.revoked_at IS NULL\n AND (ub.ends_at IS NULL OR ub.ends_at > CURRENT_TIMESTAMP)\n ORDER BY ub.starts_at DESC\n LIMIT 1\n ) active_ban ON TRUE\n JOIN chat_read_states crs\n ON crs.room_id = rm.room_id\n AND crs.user_id = rm.user_id\n WHERE rm.room_id = $1\n AND ($2::BIGINT IS NULL OR rm.user_id <> $2)\n AND (\n (crs.last_read_event_sequence IS NOT NULL\n AND $3::BIGINT IS NOT NULL\n AND crs.last_read_event_sequence >= $3)\n OR (crs.last_read_message_created_at IS NOT NULL\n AND crs.last_read_message_id IS NOT NULL\n AND (crs.last_read_message_created_at, crs.last_read_message_id)\n > ($4, $5))\n OR ($3::BIGINT IS NULL\n AND crs.last_read_message_created_at IS NOT NULL\n AND crs.last_read_message_id IS NOT NULL\n AND (crs.last_read_message_created_at, crs.last_read_message_id)\n = ($4, $5))\n )\n ORDER BY crs.updated_at ASC, u.username ASC, u.id ASC\n LIMIT $6 OFFSET $7\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "id!: UserId",
"type_info": "Int8",
"origin": {
"Table": {
"table": "users",
"name": "id"
}
}
},
{
"ordinal": 1,
"name": "username!",
"type_info": "Varchar",
"origin": {
"Table": {
"table": "users",
"name": "username"
}
}
},
{
"ordinal": 2,
"name": "role!: crate::models::UserRole",
"type_info": "Int2",
"origin": {
"Table": {
"table": "users",
"name": "role"
}
}
},
{
"ordinal": 3,
"name": "avatar_file_reference_id",
"type_info": "Int8",
"origin": {
"Table": {
"table": "users",
"name": "avatar_file_reference_id"
}
}
},
{
"ordinal": 4,
"name": "status!: crate::models::UserStatus",
"type_info": "Int2",
"origin": "Expression"
},
{
"ordinal": 5,
"name": "is_banned!",
"type_info": "Bool",
"origin": "Expression"
},
{
"ordinal": 6,
"name": "banned_at?",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "user_bans",
"name": "starts_at"
}
}
},
{
"ordinal": 7,
"name": "banned_by?: UserId",
"type_info": "Int8",
"origin": {
"Table": {
"table": "user_bans",
"name": "banned_by"
}
}
},
{
"ordinal": 8,
"name": "banned_reason",
"type_info": "Text",
"origin": {
"Table": {
"table": "user_bans",
"name": "reason"
}
}
},
{
"ordinal": 9,
"name": "signup_method!: crate::models::SignupMethod",
"type_info": "Int2",
"origin": {
"Table": {
"table": "users",
"name": "signup_method"
}
}
},
{
"ordinal": 10,
"name": "created_at!",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "users",
"name": "created_at"
}
}
},
{
"ordinal": 11,
"name": "updated_at!",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "users",
"name": "updated_at"
}
}
},
{
"ordinal": 12,
"name": "version!",
"type_info": "Int4",
"origin": {
"Table": {
"table": "users",
"name": "version"
}
}
},
{
"ordinal": 13,
"name": "deleted_at",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "users",
"name": "deleted_at"
}
}
},
{
"ordinal": 14,
"name": "read_at!",
"type_info": "Timestamptz",
"origin": {
"Table": {
"table": "chat_read_states",
"name": "updated_at"
}
}
}
],
"parameters": {
"Left": [
"Int8",
"Int8",
"Int8",
"Timestamptz",
"Int8",
"Int8",
"Int8"
]
},
"nullable": [
false,
false,
false,
true,
null,
null,
false,
true,
true,
false,
false,
false,
false,
true,
false
]
},
"hash": "c48ec8c1f7bfd8dc0c1a0df3fb874247fa334c591e3dd4781bf270e3aa65f110"
}