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

allow to use first method as aliased select #1784

Merged
merged 2 commits into from Nov 18, 2016
Merged

Conversation

@skarbovskiy
Copy link
Contributor

@skarbovskiy skarbovskiy commented Nov 17, 2016

allow to write something like this

let subselect = knex.first('column').from('table2 as t2')
  .where(knex.raw('t2.ref_id = t1.id'))
  .orderBy('t2.created_at', 'desc').as('column');

let query = knex('table1 as t1')
  .first('t1.*', subselect)
  .where({'t1.id': id, 't1.removed_at': null});

without necessity to do knex.select().limit().as('alias')

@skarbovskiy skarbovskiy changed the title allow to use first method as aliased select allow to use first method as aliased select Nov 17, 2016
@elhigu
Copy link
Member

@elhigu elhigu commented Nov 18, 2016

Hi,

If I understood correctly this is bugfix to a feature that is already documented?

As far as I can tell the changes seem reasonable, however this PR needs test case to make sure that this feature won't break afterwards. Please check CONTRIBUTING.md.

@elhigu elhigu merged commit 9848145 into knex:master Nov 18, 2016
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@elhigu
Copy link
Member

@elhigu elhigu commented Nov 18, 2016

Thanks!

elhigu added a commit to elhigu/knex that referenced this pull request Feb 15, 2017
* allow to use first method as aliased select

* added test case for allow `first as` syntax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants