X Tutup
The Wayback Machine - https://web.archive.org/web/20201209034307/https://github.com/volatiletech/sqlboiler/issues/809
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order of columns matter in eager loading, it causes problems sometimes #809

Open
vladvelici opened this issue Jul 27, 2020 · 1 comment
Open

Comments

@vladvelici
Copy link
Contributor

@vladvelici vladvelici commented Jul 27, 2020

Hello.

This is somewhat related to #587 but it's not about selecting custom columns. It's about making the order of the columns in the database irrelevant for the queries by getting rid of select *.

Use case: It's not important most of time time, but we encounter this problem in our development when we use migrations. With postgres you can't specify the position of columns. If an up migration removes a column and a down migration re-adds it, the order of the columns is not preserved after a migrate up followed by migrate down operation (which happens often in development and reviewing pull requests).

A fix would be to generate queries that specifically select columns by name as opposed to select * in eager loading methods - this way even if the columns in the database are different and models weren't regenerated, the application won't crash. Is this a complicated change? Would this be fixed anyway by the implementation of #587?

Using sqlboiler v4.2.0 with postgres 9.6 if it's relevant.

@aarondl
Copy link
Member

@aarondl aarondl commented Aug 10, 2020

Hi @vladvelici. I think this is a fine change to go ahead and implement. In reality select * probably should never have been used. And we even did workarounds for it to exist when say adding a column the sqlboiler generated code didn't know about yet via a different application (made Bind work so that it ignores columns it doesn't find, rather than exploding as is proper).

I think that if we were to go back to this, bind should start failing if it finds column results for which it has no place to bind to again.

I don't believe it's a very complicated change.

inoc603 added a commit to inoc603/sqlboiler that referenced this issue Oct 12, 2020
…tionships

As stated in volatiletech#809, the
order of columns may cause errors during eager loading. This commits
only replaces `select *` in m2m relationships eager loading with actual
column names, since this is the only place eager loaded data is scanned
manually with generated code.

Change-Id: I6fe775ed672a1ef303385b362898402f468108fe
inoc603 added a commit to inoc603/sqlboiler that referenced this issue Oct 12, 2020
…tionships

As stated in volatiletech#809, the
order of columns may cause errors during eager loading. This commits
only replaces `select *` in m2m relationships eager loading with actual
column names, since this is the only place eager loaded data is scanned
manually with generated code.

Change-Id: I173761a2b4ab0777cbe093bd50a81c561cef506a
inoc603 added a commit to inoc603/sqlboiler that referenced this issue Oct 12, 2020
…tionships

As stated in volatiletech#809, the
order of columns may cause errors during eager loading. This commits
only replaces `select *` in m2m relationships eager loading with actual
column names, since this is the only place eager loaded data is scanned
manually with generated code.
inoc603 added a commit to inoc603/sqlboiler that referenced this issue Oct 12, 2020
…tionships

As stated in volatiletech#809, the
order of columns may cause errors during eager loading. This commits
only replaces `select *` in m2m relationships eager loading with actual
column names, since this is the only place eager loaded data is scanned
manually with generated code.
inoc603 added a commit to inoc603/sqlboiler that referenced this issue Oct 12, 2020
…tionships

As stated in volatiletech#809, the
order of columns may cause errors during eager loading. This commits
only replaces `select *` in m2m relationships eager loading with actual
column names, since this is the only place eager loaded data is scanned
manually with generated code.
inoc603 added a commit to inoc603/sqlboiler that referenced this issue Oct 12, 2020
…tionships

As stated in volatiletech#809, the
order of columns may cause errors during eager loading. This commits
only replaces `select *` in m2m relationships eager loading with actual
column names, since this is the only place eager loaded data is scanned
manually with generated code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.
X Tutup