1 | from ..adapters.couchdb import CouchDB |
---|
2 | from .base import NoSQLDialect |
---|
3 | from . import dialects |
---|
4 | |
---|
5 | |
---|
6 | @dialects.register_for(CouchDB) |
---|
7 | class CouchDBDialect(NoSQLDialect): |
---|
8 | def _and(self, first, second, query_env={}): |
---|
9 | return "(%s && %s)" % ( |
---|
10 | self.expand(first, query_env=query_env), |
---|
11 | self.expand(second, query_env=query_env), |
---|
12 | ) |
---|
13 | |
---|
14 | def _or(self, first, second, query_env={}): |
---|
15 | return "(%s || %s)" % ( |
---|
16 | self.expand(first, query_env=query_env), |
---|
17 | self.expand(second, query_env=query_env), |
---|
18 | ) |
---|
19 | |
---|
20 | def eq(self, first, second=None, query_env={}): |
---|
21 | if second is None: |
---|
22 | return "(%s == null)" % self.expand(first, query_env=query_env) |
---|
23 | return "(%s == %s)" % ( |
---|
24 | self.expand(first, query_env=query_env), |
---|
25 | self.expand(second, first.type, query_env=query_env), |
---|
26 | ) |
---|
27 | |
---|
28 | def ne(self, first, second=None, query_env={}): |
---|
29 | if second is None: |
---|
30 | return "(%s != null)" % self.expand(first, query_env=query_env) |
---|
31 | return "(%s != %s)" % ( |
---|
32 | self.expand(first, query_env=query_env), |
---|
33 | self.expand(second, first.type, query_env=query_env), |
---|
34 | ) |
---|
35 | |
---|
36 | def comma(self, first, second, query_env={}): |
---|
37 | return "%s + %s" % ( |
---|
38 | self.expand(first, query_env=query_env), |
---|
39 | self.expand(second, query_env=query_env), |
---|
40 | ) |
---|