Skip to content

Commit

Permalink
Fixes discovered during schemathesis tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rdlrt committed Sep 17, 2023
1 parent bc34d76 commit ec6097c
Show file tree
Hide file tree
Showing 16 changed files with 864 additions and 858 deletions.
8 changes: 3 additions & 5 deletions files/grest/rpc/account/account_addresses.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ BEGIN
txo.stake_address_id,
txo.id
FROM tx_out AS txo
WHERE
txo.stake_address_id = ANY(sa_id_list)
AND tx_out.consumed_by_tx_in_id IS NULL
WHERE txo.stake_address_id = ANY(sa_id_list)
AND txo.consumed_by_tx_in_id IS NULL
) AS x
)

Expand All @@ -55,8 +54,7 @@ BEGIN
txo.stake_address_id,
txo.id
FROM tx_out AS txo
WHERE
txo.stake_address_id = ANY(sa_id_list)
WHERE txo.stake_address_id = ANY(sa_id_list)
LIMIT (CASE WHEN _first_only IS TRUE THEN 1 ELSE NULL END)
) AS x
)
Expand Down
4 changes: 2 additions & 2 deletions files/grest/rpc/account/account_txs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ BEGIN
FROM public.tx
INNER JOIN public.block AS b ON b.id = tx.block_id
WHERE tx.id = ANY(_tx_id_list)
AND block.block_no >= _after_block_height
ORDER BY block.block_no DESC;
AND b.block_no >= _after_block_height
ORDER BY b.block_no DESC;
END;
$$;

Expand Down
4 changes: 2 additions & 2 deletions files/grest/rpc/address/address_txs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ BEGIN
FROM public.tx
INNER JOIN public.block AS b ON b.id = tx.block_id
WHERE tx.id = ANY(_tx_id_list)
AND block.block_no >= _after_block_height
ORDER BY block.block_no DESC;
AND b.block_no >= _after_block_height
ORDER BY b.block_no DESC;
END;
$$;

Expand Down
4 changes: 2 additions & 2 deletions files/grest/rpc/address/credential_txs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ BEGIN
FROM public.tx
INNER JOIN public.block AS b ON b.id = tx.block_id
WHERE tx.id = ANY(_tx_id_list)
AND block.block_no >= _after_block_height
ORDER BY block.block_no DESC;
AND b.block_no >= _after_block_height
ORDER BY b.block_no DESC;
END;
$$;

Expand Down
2 changes: 1 addition & 1 deletion files/grest/rpc/assets/asset_addresses.sql
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ BEGIN
FROM ma_tx_out AS mto
INNER JOIN tx_out AS txo ON txo.id = mto.tx_out_id
WHERE mto.ident = _asset_id
AND tx_out.consumed_by_tx_in_id IS NULL
AND txo.consumed_by_tx_in_id IS NULL
) AS x
GROUP BY x.address;
END;
Expand Down
5 changes: 2 additions & 3 deletions files/grest/rpc/assets/asset_txs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,14 @@ BEGIN
INNER JOIN tx_out AS txo ON txo.id = mto.tx_out_id
INNER JOIN tx ON tx.id = txo.tx_id
INNER JOIN block ON block.id = tx.block_id
LEFT JOIN tx_in AS txi ON txo.tx_id = txi.tx_out_id
AND txo.index::smallint = txi.tx_out_index::smallint
WHERE
mto.ident = _asset_id
AND block.block_no >= _after_block_height
AND (_history = TRUE OR txi.id IS NULL)
AND (_history = TRUE OR txo.consumed_by_tx_in_id IS NULL)
GROUP BY
ident,
tx.hash,
txo.index::smallint,
block.epoch_no,
block.block_no,
block.time
Expand Down
5 changes: 2 additions & 3 deletions files/grest/rpc/assets/asset_utxos.sql
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@ BEGIN
LEFT JOIN block AS b ON b.id = tx.block_id
LEFT JOIN datum ON datum.id = tx_out.inline_datum_id
LEFT JOIN script ON script.tx_id = tx_out.reference_script_id
LEFT JOIN _assets ON tx_out.id = _assets.id
WHERE mto.ident = ANY(_asset_id_list)
AND tx_out.consumed_by_tx_in_id IS NULL
INNER JOIN _assets ON tx_out.id = _assets.id
WHERE tx_out.consumed_by_tx_in_id IS NULL
;
END;
$$;
Expand Down
2 changes: 1 addition & 1 deletion files/grest/rpc/assets/policy_asset_addresses.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ BEGIN
FROM _all_assets AS aa
INNER JOIN ma_tx_out AS mto ON mto.ident = aa.id
INNER JOIN tx_out AS txo ON txo.id = mto.tx_out_id
WHERE tx_out.consumed_by_tx_in_id IS NULL
WHERE txo.consumed_by_tx_in_id IS NULL
) AS x
GROUP BY
x.asset_name,
Expand Down
6 changes: 3 additions & 3 deletions files/grest/rpc/pool/pool_metadata.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ BEGIN
pic.meta_hash,
pod.json,
pic.pool_status
FROM grest.pool_hash AS ph
LEFT JOIN grest.pool_infor_cache AS pic ON ph.view = pic.pool_id_bech32
FROM public.pool_hash AS ph
LEFT JOIN grest.pool_info_cache AS pic ON ph.view = pic.pool_id_bech32
LEFT JOIN public.pool_offline_data AS pod ON pod.pmr_id = pic.meta_id
WHERE
CASE
WHEN _pool_bech32_ids IS NULL THEN TRUE
WHEN _pool_bech32_ids IS NOT NULL THEN pic.pool_id_bech32 = ANY(SELECT UNNEST(_pool_bech32_ids))
END
ORDER BY
ph.view,
pic.pool_id_bech32,
pic.tx_id DESC;
END;
$$;
Expand Down
Loading

0 comments on commit ec6097c

Please sign in to comment.