Does someone know how to pass string array in postgreSQL in Exposed(kotlin framework)

There's jetbrains kotlin framework named Exposed and it's for DB. I'm trying to pass array to postgresql but there's no functions to do it, maybe someone knows how to do it?
16 Replies
JavaBot
JavaBot15mo ago
This post has been reserved for your question.
Hey @S.R.M! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
dan1st
dan1st15mo ago
What does the SQL query look like? Are you using IN?
dan1st
dan1st15mo ago
Stack Overflow
How to add array Column type in Jetbrains Exposed
I am trying to add a column of type array to my Postgres table using exposed.The goal is to have a statement like: UPDATE posts SET like_user_id = like_user_id || $1, likes = likes +...
GitHub
Array column type support · Issue #150 · JetBrains/Exposed
Do you have any plan to support array column support?
AdoMuta
AdoMutaOP15mo ago
well Idk, i was just using functions from exposed, im really green in sql and i'm creating tables with pgadmin4
dan1st
dan1st15mo ago
Can you show the queries you were doing?
AdoMuta
AdoMutaOP15mo ago
i already saw the second link i found some custom functions but i'm not sure if they are working so i'm testing it you mean show sql table?
dan1st
dan1st15mo ago
Well, what exactly are you trying to do? ig maybe the table could help as well passing arrays or similar isn't really something SQL DBs are good at
AdoMuta
AdoMutaOP15mo ago
well i'm trying to send in database array of URL of images here auto generate sql code
CREATE TABLE IF NOT EXISTS public.profile
(
login character varying(25) COLLATE pg_catalog."default" NOT NULL,
username character varying(25) COLLATE pg_catalog."default" NOT NULL,
description character varying(300) COLLATE pg_catalog."default",
images character varying(100)[] COLLATE pg_catalog."default",
tags character varying(100)[] COLLATE pg_catalog."default",
CONSTRAINT profile_pkey PRIMARY KEY (login)
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.profile
OWNER to postgres;
CREATE TABLE IF NOT EXISTS public.profile
(
login character varying(25) COLLATE pg_catalog."default" NOT NULL,
username character varying(25) COLLATE pg_catalog."default" NOT NULL,
description character varying(300) COLLATE pg_catalog."default",
images character varying(100)[] COLLATE pg_catalog."default",
tags character varying(100)[] COLLATE pg_catalog."default",
CONSTRAINT profile_pkey PRIMARY KEY (login)
)

TABLESPACE pg_default;

ALTER TABLE IF EXISTS public.profile
OWNER to postgres;
dan1st
dan1st15mo ago
yeah so normally you wouldn't have arrays in the DB instead, you would have a different table e.g. a table profile_images with a column for the image name and profile ID (foreign key) similar for tags
AdoMuta
AdoMutaOP15mo ago
arent arrays made for this? like i thought for these things arrays are made but if arrays is bad practice for DB then i'll do what you said
dan1st
dan1st15mo ago
arrays don't work the same way in all database systems some databases might even not support arrays at all I don't really know about postgres but in my experience, arrays are somewhat difficult With SQL databases, you typically want your schema to be in a normal form
AdoMuta
AdoMutaOP15mo ago
hmmmm, okay then i'll do it instead of my decision
dan1st
dan1st15mo ago
which means only one thing per column (1. NF), stuff should only be dependent on the full primary key (2. NF) and stuff shouldn't transitively depend on content from non-primary keys (3. NF) these things can help when it comes to avoiding redundancy/inconsistencies
AdoMuta
AdoMutaOP15mo ago
oh well thank you, that will help me so much
JavaBot
JavaBot15mo ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
JavaBot
JavaBot15mo ago
Post Closed
This post has been closed by <@399891918428831754>.

Did you find this page helpful?