I have a table with id as int8 primary key. I have...
# help
a
I have a table with id as int8 primary key. I have inserted 10 rows from SQL editor, now when I use supabase-py to insert it does not use the correct increment on insert, it seems to not know about already inserted columns and starts generating primary key from 1 instead of 11.
n
Hello @ak4zh! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
s
Is that column set to autoincrement inside the table?
n
keeplearning (2022-03-12)
a
Yes table is created with dashboard without making any change in id field so auto increment, primary key everything is applied.
s
If the database table is set to autoincrement that column then it should work because the library doesn't decide how that field works, unless you are forcing the insert of a value for the id column
a
I have verified the primary keys does not auto increment if you insert from SQL with id hard coded. So it's probably a postgres things nothing to do with supa.
Copy code
sql
CREATE TABLE public.people (
    id SERIAL PRIMARY KEY,
    name text NOT NULL
);

-- this will insert the rows
INSERT INTO public.people
    (id, name)
VALUES
    (1, 'foo'),
    (2, 'bar');

-- this query will try to push rows from id 1
-- so will fail n times, n = number of rows inserted manually with id
INSERT INTO public.people
    (name)
VALUES
    ('nfoo'),
    ('nbar');
s
If the field is autoincremented you can't push your own id's to it, that sort of defeats the purpose of autoincrement