def test_select_no_with_alias_from(self): q = Query.select(ValueWrapper(1, 'test')) self.assertEqual('SELECT 1 "test"', str(q))
def test__length__str(self): q = Query.select(fn.Length('ABC')) self.assertEqual("SELECT LENGTH('ABC')", str(q))
def test_select_then_add_table(self): q = Query.select(1).select(2, 3).from_('abc').select('foo') self.assertEqual('SELECT 1,2,3,"foo" FROM "abc"', str(q))
def test__bin__int(self): q = Query.select(fn.Bin(2)) self.assertEqual("SELECT BIN(2)", str(q))
def test__insert__str(self): q = Query.select(fn.Insert('Quadratic', 3, 4, 'What')) self.assertEqual("SELECT INSERT('Quadratic',3,4,'What')", str(q))
def test_instance_from_function_removed_after_called(self): with self.assertRaises(AttributeError): Query.select(1).from_('abc').from_('efg')
def test__ascii__int(self): q = Query.select(fn.Ascii(2)) self.assertEqual("SELECT ASCII(2)", str(q))
def test__length__str(self): q = Q.select(fn.Length("ABC")) self.assertEqual("SELECT LENGTH('ABC')", str(q))
def test_now(self): query = Query.select(fn.Now()) self.assertEqual("SELECT NOW()", str(query))
def test__insert__str(self): q = Q.select(fn.Insert("Quadratic", 3, 4, "What")) self.assertEqual("SELECT INSERT('Quadratic',3,4,'What')", str(q))
def test__lower__str(self): q = Q.select(fn.Lower("ABC")) self.assertEqual("SELECT LOWER('ABC')", str(q))
def test__concat__str(self): q = Q.select(fn.Concat("p", "y", "q", "b")) self.assertEqual("SELECT CONCAT('p','y','q','b')", str(q))
def test__bin__int(self): q = Q.select(fn.Bin(2)) self.assertEqual("SELECT BIN(2)", str(q))
def test__bin__str(self): q = Q.select(fn.Bin("2")) self.assertEqual("SELECT BIN('2')", str(q))
def test__ascii__int(self): q = Q.select(fn.Ascii(2)) self.assertEqual("SELECT ASCII(2)", str(q))
def test_utc_timestamp(self): query = Query.select(fn.UtcTimestamp()) self.assertEqual("SELECT UTC_TIMESTAMP()", str(query))
def test_current_time(self): query = Query.select(fn.CurTime()) self.assertEqual("SELECT CURRENT_TIME()", str(query))
def test_current_date(self): query = Query.select(fn.CurDate()) self.assertEqual("SELECT CURRENT_DATE()", str(query))
def test__ascii__str(self): q = Query.select(fn.Ascii('2')) self.assertEqual("SELECT ASCII('2')", str(q))
def test_current_timestamp(self): query = Query.select(fn.CurTimestamp()) self.assertEqual("SELECT CURRENT_TIMESTAMP", str(query))
def test__bin__str(self): q = Query.select(fn.Bin('2')) self.assertEqual("SELECT BIN('2')", str(q))
def test_current_timestamp_with_alias(self): query = Query.select(fn.CurTimestamp("ts")) self.assertEqual('SELECT CURRENT_TIMESTAMP "ts"', str(query))
def test__concat__str(self): q = Query.select(fn.Concat('p', 'y', 'q', 'b')) self.assertEqual("SELECT CONCAT('p','y','q','b')", str(q))
def test_select__no_table(self): q = Query.select(1, 2, 3) self.assertEqual('SELECT 1,2,3', str(q))
def test__lower__str(self): q = Query.select(fn.Lower('ABC')) self.assertEqual("SELECT LOWER('ABC')", str(q))
def test_select_no_from(self): q = Query.select(1) self.assertEqual('SELECT 1', str(q))
def test_select_no_from_with_field_raises_exception(self): with self.assertRaises(QueryException): Query.select('asdf')
def test__ascii__str(self): q = Q.select(fn.Ascii("2")) self.assertEqual("SELECT ASCII('2')", str(q))