Skip to content

Fetch lastInsertId only when id null - #13086

Merged
rullzer merged 2 commits into
masterfrom
bugfix/dont-query-when-id-not-null
Dec 27, 2018
Merged

Fetch lastInsertId only when id null#13086
rullzer merged 2 commits into
masterfrom
bugfix/dont-query-when-id-not-null

Conversation

@kesselb

@kesselbkesselb commented Dec 15, 2018

Copy link
Copy Markdown
Contributor

When id column has no autoincrement flag query for lastInsertId fails
on postgres because no value has been generated. Call lastInsertId only
if id is null.

Could you consider a backport? Social App does not work on postgres without this like reported here #12465 (comment). Not sure how "safe" it is to backport it.

@kesselbkesselb added this to the Nextcloud 16 milestone Dec 15, 2018
@kesselbkesselb added bug 3. to review Waiting for reviews labels Dec 15, 2018
@nickvergessen

Copy link
Copy Markdown
Member

I always wonder if we should have a separate model for stuff that does nto have an autoincrement ID or no ID at all.

@rullzer

Copy link
Copy Markdown
Member

Isn't id null by default if you don't init it?

@kesselb

kesselb commented Dec 17, 2018

Copy link
Copy Markdown
ContributorAuthor

Isn't id null by default if you don't init it?

By default id is null

@rullzer

Copy link
Copy Markdown
Member

So then how does this fix it? As on insert of new data it will anyways be null right?

@nickvergessen

Copy link
Copy Markdown
Member

Well @rullzer the problem is the social app uses this for a model without autoincrement, the column is not even in 32bit integer anymore:
https://github.com/nextcloud/social/blob/b7ac669cb3cbd66fb36f1c1100d2508ca846863e/lib/Service/ActivityPub/NoteService.php#L143

@rullzer

Copy link
Copy Markdown
Member

Ah it is set there. OK. Yeah I think having a special entity would make sense. But for now lets do this.

When id column has no autoincrement flag query for lastInsertId fails
on postgres because no value has been generated. Call lastInsertId only
if id is null.
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Some implementations typehint getId to integer but default is null.
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
@rullzer
rullzerforce-pushed the bugfix/dont-query-when-id-not-null branch from 8fcef56 to 8a952b7CompareDecember 24, 2018 13:21
@rullzer
rullzer merged commit bb3a7ad into masterDec 27, 2018
@rullzer
rullzer deleted the bugfix/dont-query-when-id-not-null branch December 27, 2018 09:02
@kesselb

Copy link
Copy Markdown
ContributorAuthor

/backport to stable15

@backportbot-nextcloud

Copy link
Copy Markdown

backport to stable15 in #13278

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviewsbug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@kesselb@nickvergessen@rullzer