def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): t = Table('table1') subquery = OracleQuery.from_(t).select(t.abc) col = subquery.abc.as_('a') q = OracleQuery.from_(subquery).select(col, Count('*')).groupby(col) self.assertEqual('SELECT sq0.abc a,COUNT(\'*\') FROM (SELECT abc FROM table1) sq0 GROUP BY sq0.abc', str(q))
def test_oracle_query_uses_double_quote_chars(self): q = (OracleQuery.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))
def test_oracle_query_uses_double_quote_chars(self): q = OracleQuery.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))
def test_groupby__no_alias_oracle(self): bar = self.t.bar.as_("bar01") q = OracleQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) self.assertEqual('SELECT SUM(foo),bar bar01 FROM abc GROUP BY bar', str(q))
def test_oracle_query_uses_no_quote_chars(self): q = ( OracleQuery.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))
def test_oracle_query_uses_double_quote_chars(self): q = OracleQuery.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))
def test_oracle_query_uses_double_quote_chars(self): q = OracleQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q))
def test_oracle_query_uses_double_quote_chars(self): q = OracleQuery.from_("abc").select("foo", "bar") self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q))
def test__regexp_like__field_with_oracle_dialect(self): q = OracleQuery.from_(self.t).select( fn.RegexpLike(self.t.foo, '^a', 'x')) self.assertEqual( "SELECT REGEXP_LIKE(\"foo\",\'^a\',\'x\') FROM \"abc\"", str(q))
def test__split_part__field_with_oracle_dialect(self): q = OracleQuery.from_(self.t).select(fn.SplitPart(self.t.foo, '|', 3)) self.assertEqual( "SELECT REGEXP_SUBSTR(\"foo\",\'[^|]+\',1,3) FROM \"abc\"", str(q))
def test_oracle_query_uses_double_quote_chars(self): q = OracleQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q))
def test_oracle_query_uses_double_quote_chars(self): q = OracleQuery.from_('abc').select('foo', 'bar') self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q))
def test_oracle_query_uses_no_quote_chars(self): q = OracleQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) self.assertEqual('SELECT foo FROM abc GROUP BY foo', str(q))
def test_oracle_query_uses_no_quote_chars(self): q = OracleQuery.from_("abc").select("foo", "bar") self.assertEqual('SELECT foo,bar FROM abc', str(q))
def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): t = Table('table1') col = t.abc.as_('a') q = OracleQuery.from_(t).select(col, Count('*')).groupby(col) self.assertEqual('SELECT abc a,COUNT(\'*\') FROM table1 GROUP BY abc', str(q))