Comments (4)
Hi @palkan, thanks for looking into this so quickly.
This gem is brilliant btw, thank you so much for your effort.
I see that the docs for hstore_to_jsonb_loose say:
get hstore as a jsonb value, but attempt to distinguish numerical and Boolean values so they are unquoted in the JSON
This is exactly the problem.
It looks as though this should have been fixed in 9.6 commited postgres/postgres@e09996f#diff-0f8b296e470f9ba30622ac12b4cea554 and again amended postgres/postgres@41d2c08#diff-0f8b296e470f9ba30622ac12b4cea554
Make contrib/hstore's hstore_to_jsonb_loose() and hstore_to_json_loose() functions agree on what is a number (Tom Lane)
Previously, hstore_to_jsonb_loose() would convert numeric-looking strings to JSON numbers, rather than strings, even if they did not exactly match the JSON syntax specification for numbers. This was inconsistent with hstore_to_json_loose(), so tighten the test to match the JSON syntax.
And yet the the problem still exists. I'm going to try and look into the bug on hstore_to_jsonb_loose
a little more. For now I am working around it by base64 encoding the strings before they are inserted.
from logidze.
I think maybe this should be in the README as a possible error raised by logidze_logger()
.
We've recently gotten this a few times in
UPDATE \"tender_job_schedule_shifts\" SET \"scheduled_check_in_request_jid\" = '3981465518e9665560300635' WHERE \"tender_job_schedule_shifts\".\"id\" = 581565",
relatedly, while I'm here: I'd also appreciate if there were an error_handling function which I could define to 'rescue' any errors inside logidze without failing the transaction. I do this for a number of my other function.
e.g.
EXCEPTION
-- https://www.postgresql.org/docs/11/errcodes-appendix.html
-- https://www.postgresql.org/docs/11/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING
WHEN DEADLOCK_DETECTED OR QUERY_CANCELED OR LOCK_NOT_AVAILABLE THEN
RAISE WARNING 'APP_NOTICE: DATABASE ERROR DETECTED: function % on invoice_ids %. running: %\n', fn_name, invoice_ids, current_query();
GET STACKED DIAGNOSTICS
_db_err_sql_state := RETURNED_SQLSTATE,
_db_err_message := MESSAGE_TEXT,
_db_err_detail := PG_EXCEPTION_DETAIL,
_db_err_hint := PG_EXCEPTION_HINT,
_db_err_context := PG_EXCEPTION_CONTEXT;
IF COALESCE(current_setting('logidze.meta', true), '') <> '' THEN
_db_err_responsible_id := current_setting('logidze.meta')::text;
END IF;
INSERT INTO database_errors (
sql_state, message, detail, hint, context,
fn_name, fn_args, current_query, responsible_id
) VALUES (
_db_err_sql_state, _db_err_message, _db_err_detail, _db_err_hint, _db_err_context,
fn_name, quote_literal(invoice_ids::text), current_query()::text, _db_err_responsible_id
);
from logidze.
I believe to_jsonb is erroneously attempting to typecast the string, could this be a bug in PG?
to_jsonb
works fine http://dbfiddle.uk/?rdbms=postgres_9.6&fiddle=b1f6f9128c3db270785c15f7426583e1 (::jsonb
fails but we do not use).
The problem is with hstore_to_jsonb_loose
:
# select hstore_to_jsonb_loose('a=>557236406134e62000323100'::hstore);
ERROR: value overflows numeric format
One way to solve this is to avoid hstore
manipulations and calculate the diff using another technique (for example, this one https://github.com/palkan/logidze/blob/master/bench/triggers/keys2_trigger_setup.sql). That would be less performant though (about 1.5x).
from logidze.
@bf4 Thanks for the suggestion! Updated the Readme and will create a separate issue regarding exceptions handling.
from logidze.
Related Issues (20)
- Add Logidze.with_responsible! (block-less version)
- Logidze with Ruby 3.0 is throwing argument errors. HOT 2
- `rails destroy logidze:model MyModel` does not delete migration file HOT 2
- Activerecord table_name_prefix or table_name_suffix are not honored HOT 3
- Tracking changes on JSONB column error
- How to list all versions of a record? HOT 4
- Association versioning with ignore_log_data and at(version: ) doesn't return expected results HOT 5
- Partition-friendly logging (triggers) HOT 3
- JSONB column and switch_to! with append: true HOT 2
- PG::UndefinedFunction: ERROR: function hstore(model_name) does not exist HOT 1
- Meta per request HOT 1
- Logidze.ignore_log_data_by_default causing db:migrate errors HOT 2
- Responsible from different sources HOT 3
- Associations versioning - accessing versions with `at(version: #)` HOT 2
- How to tell logidze about a new column HOT 8
- GlobalID support for metadata
- `responsible_id` is not updated on relation with `touch: true` HOT 6
- reload_log_data doesn't work when used with acts_as_paranoid and deleted records HOT 2
- docs: logdize cannot set session meta data when using a connection pool HOT 1
- How can I get the last 100 versions of a model? regardless of the record HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from logidze.