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 seems to matter in insert into #79

Closed
silasdavis opened this issue May 18, 2020 · 3 comments
Closed

Order seems to matter in insert into #79

silasdavis opened this issue May 18, 2020 · 3 comments

Comments

@silasdavis
Copy link
Contributor

If inserting a row with a subset of the columns if the order of my subset does not match the declared order of the table columns.

For example if I insert a row with just four columns out of many set in the same order as they were declared in the table the query works as expected:

const insertParamUpdate = sql<IInsertParamUpdateQuery>`
    insert into data.event_log
    (_chainid, _height, _txindex, storage_address  )
    values
    $$params(_chainid, _height, _txindex,  storage_address);
`;

But if I swap storage_address in the column list nad the values object:

const insertParamUpdate = sql<IInsertParamUpdateQuery>`
    insert into data.event_log
    (_chainid, storage_address, _height, _txindex )
    values
    $$params(_chainid, storage_address _height, _txindex);
`;

This fails with a invalid input for type bigint. This makes it seem like storage_address is being provided for a _height value.

It's late now but a test case shouldn't be too hard if this is a general bug.

@adelsz
Copy link
Owner

adelsz commented May 18, 2020

Hm, this is interesting, column order shouldn't affect the type inference.
I can also see a comma missing on line 5 in the second code block, is that a typo?

@silasdavis
Copy link
Contributor Author

Ah yes it is, I've provided a test case in that pr

@adelsz
Copy link
Owner

adelsz commented May 22, 2020

Thanks for creating a test case! Fixed in v0.7.2.

@adelsz adelsz closed this as completed May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants