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

fixes bug when using dot in as identifier #1181

Merged
merged 1 commit into from Feb 3, 2016

Conversation

Projects
None yet
2 participants
@a0viedo
Contributor

a0viedo commented Feb 2, 2016

I've encountered what I think is a bug on the formatting of SQL statements. Take the following example:

var knex = require('knex')(config);
console.log(knex.select('id as foo.bar').from('users').toSQL());

This would print

{ method: 'select',
  options: {},
  bindings: [],
  sql: 'select "id" as "foo"."bar" from "users"' }

like trying to access a field in the alias but instead should be formatted as

{ method: 'select',
  options: {},
  bindings: [],
  sql: 'select "id" as "foo.bar" from "users"' }
@elhigu

This comment has been minimized.

Collaborator

elhigu commented Feb 3, 2016

As far as I know, the correct format is "foo"."bar". @a0viedo why do you think it is wrong?

EDIT: Looks like you are right... since it is single identifier after as it is not table/column reference, the correct quoting really seem to be as you suggest.

@elhigu

This comment has been minimized.

Collaborator

elhigu commented Feb 3, 2016

Looks like test error was just a timeout, I retriggered the build.

elhigu added a commit that referenced this pull request Feb 3, 2016

Merge pull request #1181 from a0viedo/alias-fix
fixes bug when using dot in as identifier

@elhigu elhigu merged commit 538cdee into tgriesser:master Feb 3, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@elhigu

This comment has been minimized.

Collaborator

elhigu commented Feb 3, 2016

@a0viedo good catch and thanks for the fix!

@a0viedo

This comment has been minimized.

Contributor

a0viedo commented Feb 3, 2016

@elhigu thank you!

@a0viedo a0viedo deleted the a0viedo:alias-fix branch Feb 3, 2016

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