Replies: 1 comment 1 reply
-
I'm not sure why you would expect a string to be returned instead of an integer, when the column is a bigint column. The pg_extended_integer_support extension handles how Ruby integers outside the PostgreSQL bigint range are literalized into SQL, it does not affect how integers returned from the database (which must be inside the bigint range) are treated. If you would like a string returned, it's best to cast: dataset.select(Sequel.cast(:ti_id, String), ...).first There isn't way to do this automatically, though if you are using models, you could make the model's dataset use this cast, and then all datasets based on it will also use the cast. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
CREATE TABLE IF NOT EXISTS public.user
(
ti_id bigint NOT NULL,
ti_username character varying(16) NOT NULL,
ti_created_on timestamp with time zone NOT NULL,
ti_updated_on timestamp with time zone NOT NULL,
);
db = ... ...
db.extension :pg_extended_integer_support
dataset = db[:user].where(:ti_id=>4165893557190656012)
dataset = dataset.extension(:pg_extended_integer_support)
dataset.first
Actual result:
{:ti_id=>4165893557190656012, :ti_username=>"1", :ti_created_on=>2024-01-11 10:43:02.092 +0800, :ti_updated_on=>2024-01-11 10:43:02.092 +0800}
Expected result:
{:ti_id=>”4165893557190656012“, :ti_username=>"1", :ti_created_on=>2024-01-11 10:43:02.092 +0800, :ti_updated_on=>2024-01-11 10:43:02.092 +0800}
Is there a way convert bigint to string automaticly?
Beta Was this translation helpful? Give feedback.
All reactions