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

Add boolean as a column value type in join #3121

Merged
merged 1 commit into from Mar 30, 2019

Conversation

Projects
None yet
3 participants
@felixmosh
Copy link
Contributor

felixmosh commented Mar 28, 2019

Added missing type

@@ -239,7 +239,7 @@ declare namespace Knex {
(tableName: TableName | Identifier | QueryCallback, clause: JoinCallback): QueryBuilder;
(
tableName: TableName | Identifier | QueryCallback,
columns: { [key: string]: string | number | Raw }
columns: { [key: string]: string | number | boolean | Raw }

This comment has been minimized.

Copy link
@kibertoad

kibertoad Mar 30, 2019

Collaborator

When would it be a boolean?

This comment has been minimized.

Copy link
@felixmosh

felixmosh Mar 30, 2019

Author Contributor

What do you mean?
The value of join can be boolean :)

This comment has been minimized.

Copy link
@kibertoad

kibertoad Mar 30, 2019

Collaborator

Could you please provide example code that was invalid before this change?
The way I'm reading this binding is this:

knex('users')
  .join('contacts', 'users.id', '=', 'contacts.user_id')
  .select('users.id', 'contacts.phone')

columns are these: 'users.id', '=', 'contacts.user_id'
Why would they ever be boolean?

This comment has been minimized.

Copy link
@felixmosh

felixmosh Mar 30, 2019

Author Contributor

Pay attention to the interface that I've fixed, it is the one that accepts an object.

db('tableName')
    .leftJoin('otherTable', {
      'tableName.isDefault': true
    })

image

It tries to resolve it using the Raw interface because there is no boolean.

This comment has been minimized.

Copy link
@kibertoad

kibertoad Mar 30, 2019

Collaborator

Fair enough. And if typing is fixed, DB understands boolean value correctly?

This comment has been minimized.

Copy link
@felixmosh

felixmosh Mar 30, 2019

Author Contributor

Yeah, it works, it converts it into tinyInt automatically

This comment has been minimized.

Copy link
@elhigu

elhigu Mar 30, 2019

Collaborator

Actually that depends highly on db that is used, but something like that :) I had big problems trying to write cross db compatible code that had used boolean column type.

@kibertoad kibertoad merged commit 1948c3d into tgriesser:master Mar 30, 2019

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage remained the same at 85.229%
Details

@kibertoad kibertoad changed the title Add boolean as a column name in join Add boolean as a column value type in join Mar 30, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.