fix: Case Sensitive Quoted Column Names Support for Context.DB #448
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Postgres treats unquoted strings as non-case-sensitive whereas quoted strings are. This means that blockHeight and "blockHeight" are in fact different and will not match. Currently, context.db puts column names without quotes. This leads to a mismatch causing the column to not be found:
INSERT INTO nearpavel_near_staking_v3."receipts" (blockHeight, blockHash, blockTimestamp, blockDate, depositIn, receiptId, predecessorId, signerId, validatorId) VALUES ('106896621', '8o26GZfSt4z7TrbHdHhDCXttXkG3hUFNkLCL33y52c1d', '1701388833845.7158', '2023-12-01', '900000000000000000000000', 'AZhuyEwThxEHUyUcudiNJ49pBhMekgjgokj9tmfHEgkg', '2ee9129228b532b25181ec6cbd1e09bf058e5169c9a9606fec69b5f635423d97', '2ee9129228b532b25181ec6cbd1e09bf058e5169c9a9606fec69b5f635423d97', 'astro-stakers.poolv1.near') ON CONFLICT (receiptId) DO UPDATE SET depositIn = excluded.depositIn RETURNING *
column "blockheight" of relation "receipts" does not exist
The fix is to quote the column names in the query, if they were quoted in the schema.
In addition, the logs for context.db were being written under the wrong function name. I fixed that too.