Skip to content

Added support for 'boolean' type.#87

Merged
mistic100 merged 1 commit intomistic100:masterfrom
cmrbck:master
Feb 13, 2015
Merged

Added support for 'boolean' type.#87
mistic100 merged 1 commit intomistic100:masterfrom
cmrbck:master

Conversation

@cmrbck
Copy link
Contributor

@cmrbck cmrbck commented Feb 12, 2015

No description provided.

@mistic100
Copy link
Owner

I don't see the gain over an int. people will always use a radios group or a selectbox for yes/no values so possible values are already filtered

and what if I want yes/no or 1/0 instead of true/false ? (like PHP filter_var() accept)


also this

!!(value.trim().toLowerCase() === "true")

is useless, same as

value.trim().toLowerCase() === "true"

(and is jshint compliant)

@cmrbck
Copy link
Contributor Author

cmrbck commented Feb 12, 2015

The use case I see this for is when you want to compare against a field of type boolean that ONLY contains true or false values. Currently there doesn't seem to be a way to do this (at least, I can't figure out how).

For example, I want to do a query and return only the records that contain the field 'foo' with a value of true.
A valid mongo query for this would look like:
{"$and":[{"foo":true}]}

Using int for this won't work, for example:
{"$and":[{"foo":1}]} (Returns 0 records)

Using string for this also doesn't work:
{"$and":[{"foo":"true"}]} (Returns 0 records)

@mistic100
Copy link
Owner

ok I though Mongo accepts ints as bools

but you have a problem in the SQL plugin, without prepared statement the boolean is concatenated to the string, resulting in "true"/"false" and not "1"/"0" (it might work on MySQL but certainly not on others DBMS)

and with prepared statement I am not sure what will happen (depends on engine ?)


I won't merge until you or I find a nice solution to also accept (and convert) at least 0 and 1 as raw values

@mistic100
Copy link
Owner

It would be nice if you could squash your commits when done (rebase -i then push --force)

mistic100 added a commit that referenced this pull request Feb 13, 2015
Added support for 'boolean' type.
@mistic100 mistic100 merged commit d23fb5a into mistic100:master Feb 13, 2015
@mistic100 mistic100 added this to the 1.4.2 milestone Feb 13, 2015
@mistic100 mistic100 added the feature New feature label Feb 13, 2015
@cmrbck
Copy link
Contributor Author

cmrbck commented Feb 13, 2015

Thanks!

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

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments