1602 / jugglingdb

Multi-database ORM for nodejs: redis, mongodb, mysql, sqlite3, postgresql, arango, in-memory...
http://1602.github.io/jugglingdb/
2.04k stars 241 forks source link

Adding tests for the OR functionality #317

Closed tolgaek closed 11 years ago

tolgaek commented 11 years ago

This is adding tests for the #96. Once the tests are merged in, I will start implementing it for the mysql adapter

dgsan commented 11 years ago

Mysql adapter currently supports a syntax like:

UserData.all({ where: { or: [{order_id: 1}, {order_id: 5}] }}, function(err, data){});

Which is exactly like yours, except it's using or instead of $or, and it's probably possible to do both.

I wouldn't mind seeing it also support a syntax like:

UserData.all({ where: { order_id: [1, 5] }}, function(err, data){});

but I'm guessing it would cause problems for some reason.

tolgaek commented 11 years ago

I think it would be pretty straight forward to implement or operator for array of values.. I can add that..

I know mysql implemented it, I just wanted to standardize it across the platform.. also I think the $ notation is important to avoid mistaking column names and operators in the where clauses On 2013-08-21 7:54 PM, "dgsan" notifications@github.com wrote:

Mysql adapter currently supports a syntax like:

UserData.all({ where: { or: [{order_id: 1}, {order_id: 5}] }}, function(err, data){});

Which is exactly like yours, except it's using or instead of $or, and it's probably possible to do both.

I wouldn't mind seeing it also support a syntax like:

UserData.all({ where: { order_id: [1, 5] }}, function(err, data){});

but I'm guessing it would cause problems for some reason.

— Reply to this email directly or view it on GitHubhttps://github.com/1602/jugglingdb/pull/317#issuecomment-23059575 .

tolgaek commented 11 years ago

I was just thinking about the array for doing or on a single attribute. I think it might be better to use the $in from mongo since this would allow for more extensibility..

where ; {orderId : { $in : [1, 2] }}

1602 commented 11 years ago

I don't like merging failing tests into stable branch. It is misleading. '$' sign before 'or' is not necessary too.

dgsan commented 11 years ago

I think they'd pass on mysql adapter without the '$' sign.

anatoliychakkaev commented 11 years ago

That means these tests should be in mysql adapter.

On Thu, Aug 22, 2013 at 8:07 PM, dgsan notifications@github.com wrote:

I think they'd pass on mysql adapter without the '$' sign.

— Reply to this email directly or view it on GitHubhttps://github.com/1602/jugglingdb/pull/317#issuecomment-23102443 .

tolgaek commented 11 years ago

I thought the intention was to have to have the core adapt this, if so I can implement this for Memory and recommit the tests without the $ sign

On Fri, Aug 23, 2013 at 4:43 AM, Anatoliy Chakkaev <notifications@github.com

wrote:

That means these tests should be in mysql adapter.

On Thu, Aug 22, 2013 at 8:07 PM, dgsan notifications@github.com wrote:

I think they'd pass on mysql adapter without the '$' sign.

— Reply to this email directly or view it on GitHub< https://github.com/1602/jugglingdb/pull/317#issuecomment-23102443> .

— Reply to this email directly or view it on GitHubhttps://github.com/1602/jugglingdb/pull/317#issuecomment-23150784 .

I. Tolga Ekmen tolga.ekmen@gmail.com 647 624 6111

dgsan commented 11 years ago

@anatoliychakkaev : Is there a good reason that OR queries shouldn't be possible on all JDBs? It seems basic enough that it should have a common interface in core. Or do you think the way the postgres adapter handles OR should be different than how mysql adapter does? At minimum it seems like the interface should be shared between SQL-based jdb adapters.

anatoliychakkaev commented 11 years ago

@dgsan at some point all adapters should support it, so we can put it in some optional test bucket, which can be included in adapter, but not in common tests, because it will cause failure which doesn't makes sense.

On Fri, Aug 23, 2013 at 8:54 PM, dgsan notifications@github.com wrote:

@anatoliychakkaev https://github.com/anatoliychakkaev : Is there a good reason that OR queries shouldn't be possible on all JDBs? It seems basic enough that it should have a common interface in core. Or do you think the way the postgres adapter handles OR should be different than how mysql adapter does? At minimum it seems like the interface should be shared between SQL-based jdb adapters.

— Reply to this email directly or view it on GitHubhttps://github.com/1602/jugglingdb/pull/317#issuecomment-23176371 .

Thanks, Anatoliy Chakkaev

TangMonk commented 7 years ago

How's the work?