def test_adv_select_values(self): s = SQLGenerator() self.assertEqual(s.adv_select(['column'], [('test', 't')], {}), 'SELECT column FROM test AS t') self.assertEqual( s.adv_select(['column'], [('test', 't')], {'nom': 'dupont'}), 'SELECT column FROM test AS t WHERE nom = %(nom)s')
def test_adv_select_functions(self): s = SQLGenerator() params = { 'nom': 'dupont', 'prenom': 'jean', 'age': SQLExpression('YEARS(%(date)s)', date='2013/01/01') } self.assertEqual( s.adv_select(['column'], [('test', 't')], params), 'SELECT column FROM test AS t WHERE age = YEARS(%(date)s) ' 'AND nom = %(nom)s AND prenom = %(prenom)s') self.assertEqual(params, { 'nom': 'dupont', 'prenom': 'jean', 'date': '2013/01/01' })