-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from mikeengland/add-redshift
Added Amazon Redshift dialect and timestamp/date add functions
- Loading branch information
Showing
7 changed files
with
116 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,28 +31,40 @@ | |
This contains all of the utility classes such as exceptions and decorators. | ||
""" | ||
from .enums import (Order, | ||
JoinType, | ||
DatePart) | ||
from .queries import (Query, | ||
Table, | ||
make_tables as Tables, | ||
Tuple) | ||
from .terms import (Field, | ||
Case, | ||
Not, | ||
Interval, | ||
Rollup) | ||
from .utils import (JoinException, | ||
GroupingException, | ||
CaseException, | ||
UnionException, | ||
RollupException) | ||
from .dialects import (MSSQLQuery, | ||
MySQLQuery, | ||
OracleQuery, | ||
PostgreSQLQuery, | ||
VerticaQuery) | ||
from .dialects import ( | ||
Dialects, | ||
MSSQLQuery, | ||
MySQLQuery, | ||
OracleQuery, | ||
PostgreSQLQuery, | ||
RedshiftQuery, | ||
VerticaQuery, | ||
) | ||
from .enums import ( | ||
DatePart, | ||
JoinType, | ||
Order, | ||
) | ||
from .queries import ( | ||
Query, | ||
Table, | ||
Tuple, | ||
make_tables as Tables, | ||
) | ||
from .terms import ( | ||
Case, | ||
Field, | ||
Interval, | ||
Not, | ||
Rollup, | ||
) | ||
from .utils import ( | ||
CaseException, | ||
GroupingException, | ||
JoinException, | ||
RollupException, | ||
UnionException, | ||
) | ||
|
||
__author__ = "Timothy Heys" | ||
__email__ = "[email protected]" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,3 +81,4 @@ class Dialects(Enum): | |
MSSQL = 'mssql' | ||
MYSQL = 'mysql' | ||
POSTGRESQL = 'postgressql' | ||
REDSHIFT = 'redshift' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
# coding: utf8 | ||
import unittest | ||
|
||
from pypika import (Query, | ||
Table, | ||
Tables, | ||
Field as F, | ||
Case, | ||
functions as fn, | ||
Order, | ||
MySQLQuery, | ||
VerticaQuery, | ||
MSSQLQuery, | ||
PostgreSQLQuery, | ||
OracleQuery) | ||
from pypika import ( | ||
Query, | ||
Table, | ||
Tables, | ||
Field as F, | ||
Case, | ||
functions as fn, | ||
Order, | ||
MySQLQuery, | ||
VerticaQuery, | ||
MSSQLQuery, | ||
PostgreSQLQuery, | ||
OracleQuery, | ||
RedshiftQuery, | ||
) | ||
|
||
__author__ = "Timothy Heys" | ||
__email__ = "[email protected]" | ||
|
@@ -159,11 +162,16 @@ def test_oracle_query_uses_double_quote_chars(self): | |
|
||
self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) | ||
|
||
def test_postgres_query_uses_double_quote_chars(self): | ||
def test_postgresql_query_uses_double_quote_chars(self): | ||
q = PostgreSQLQuery.from_('abc').select('foo', 'bar') | ||
|
||
self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) | ||
|
||
def test_redshift_query_uses_double_quote_chars(self): | ||
q = RedshiftQuery.from_('abc').select('foo', 'bar') | ||
|
||
self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) | ||
|
||
|
||
class WhereTests(unittest.TestCase): | ||
t = Table('abc') | ||
|
@@ -307,6 +315,11 @@ def test_postgres_query_uses_double_quote_chars(self): | |
|
||
self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) | ||
|
||
def test_redshift_query_uses_double_quote_chars(self): | ||
q = RedshiftQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) | ||
|
||
self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) | ||
|
||
|
||
class HavingTests(unittest.TestCase): | ||
table_abc, table_efg = Tables('abc', 'efg') | ||
|
@@ -404,6 +417,16 @@ def test_postgres_query_uses_double_quote_chars(self): | |
) | ||
self.assertEqual("SELECT \"foo\" FROM \"abc\" GROUP BY \"foo\" HAVING \"buz\"='fiz'", str(q)) | ||
|
||
def test_redshift_query_uses_double_quote_chars(self): | ||
q = RedshiftQuery.from_(self.table_abc).select( | ||
self.table_abc.foo | ||
).groupby( | ||
self.table_abc.foo | ||
).having( | ||
self.table_abc.buz == 'fiz' | ||
) | ||
self.assertEqual("SELECT \"foo\" FROM \"abc\" GROUP BY \"foo\" HAVING \"buz\"='fiz'", str(q)) | ||
|
||
|
||
class OrderByTests(unittest.TestCase): | ||
t = Table('abc') | ||
|