Beispiel #1
0
 def test_build_aggregate_query(self):
     sql, bind_vars = sql_builder.build_aggregate_query(table_name="my_table", id_column_name="row_id", is_asc=False)
     self.assertEqual(sql, "SELECT row_id FROM my_table ORDER BY row_id DESC " "LIMIT %(limit_row_count)s")
     self.assertEqual(bind_vars, dict(limit_row_count=1))
     sql, bind_vars = sql_builder.build_aggregate_query(table_name="my_table", id_column_name="row_id", is_asc=True)
     self.assertEqual(sql, "SELECT row_id FROM my_table ORDER BY row_id ASC " "LIMIT %(limit_row_count)s")
     self.assertEqual(bind_vars, dict(limit_row_count=1))
 def test_build_aggregate_query(self):
     sql, bind_vars = sql_builder.build_aggregate_query(
         table_name='my_table', id_column_name='row_id', is_asc=False)
     self.assertEqual(
         sql, 'SELECT row_id FROM my_table ORDER BY row_id DESC '
         'LIMIT %(limit_row_count)s')
     self.assertEqual(bind_vars, dict(limit_row_count=1))
     sql, bind_vars = sql_builder.build_aggregate_query(
         table_name='my_table', id_column_name='row_id', is_asc=True)
     self.assertEqual(
         sql, 'SELECT row_id FROM my_table ORDER BY row_id ASC '
         'LIMIT %(limit_row_count)s')
     self.assertEqual(bind_vars, dict(limit_row_count=1))
Beispiel #3
0
  def get_max(class_, cursor):
    if class_.id_column_name is None:
      raise dbexceptions.ProgrammingError("id_column_name not set.")

    query, bind_vars = sql_builder.build_aggregate_query(
        class_.table_name, class_.id_column_name, is_asc=False)
    cursor.execute(query, bind_vars)
    return cursor.fetch_aggregate_function(max)
Beispiel #4
0
    def get_max(class_, cursor):
        if class_.id_column_name is None:
            raise dbexceptions.ProgrammingError('id_column_name not set.')

        query, bind_vars = sql_builder.build_aggregate_query(
            class_.table_name, class_.id_column_name, is_asc=False)
        cursor.execute(query, bind_vars)
        return cursor.fetch_aggregate_function(max)
Beispiel #5
0
    def get_max(class_, cursor):
        if class_.id_column_name is None:
            raise dbexceptions.ProgrammingError("id_column_name not set.")

        query = sql_builder.build_aggregate_query(class_.table_name,
                                                  class_.id_column_name,
                                                  sort_func='max')
        cursor.execute(query, EmptyBindVariables)
        return cursor.fetch_aggregate_function(max)
Beispiel #6
0
  def get_max(class_, cursor):
    if class_.id_column_name is None:
      raise dbexceptions.ProgrammingError("id_column_name not set.")

    query = sql_builder.build_aggregate_query(class_.table_name,
                                              class_.id_column_name,
                                              sort_func='max')
    cursor.execute(query, EmptyBindVariables)
    return cursor.fetch_aggregate_function(max)