Пример #1
0
    def test_lookup_cast(self):
        from django.db.backends.postgresql_psycopg2.operations import DatabaseOperations

        do = DatabaseOperations(connection=None)
        for lookup in ('iexact', 'contains', 'icontains', 'startswith',
                       'istartswith', 'endswith', 'iendswith', 'regex', 'iregex'):
            self.assertIn('::text', do.lookup_cast(lookup))
Пример #2
0
    def test_lookup_cast(self):
        from django.db.backends.postgresql_psycopg2.operations import DatabaseOperations

        do = DatabaseOperations(connection=None)
        for lookup in ('iexact', 'contains', 'icontains', 'startswith',
                       'istartswith', 'endswith', 'iendswith', 'regex', 'iregex'):
            self.assertIn('::text', do.lookup_cast(lookup))
Пример #3
0
 def test_convert_values_to_handle_null_value(self):
     database_operations = DatabaseOperations(connection)
     self.assertEqual(
         None,
         database_operations.convert_values(None, AutoField(primary_key=True))
     )
     self.assertEqual(
         None,
         database_operations.convert_values(None, DateField())
     )
     self.assertEqual(
         None,
         database_operations.convert_values(None, DateTimeField())
     )
     self.assertEqual(
         None,
         database_operations.convert_values(None, DecimalField())
     )
     self.assertEqual(
         None,
         database_operations.convert_values(None, IntegerField())
     )
     self.assertEqual(
         None,
         database_operations.convert_values(None, TimeField())
     )
Пример #4
0
    def test_convert_values_to_handle_null_value(self):
        from django.db.backends.sqlite3.base import DatabaseOperations

        database_operations = DatabaseOperations(connection)
        self.assertEqual(
            None,
            database_operations.convert_values(None, AutoField(primary_key=True))
        )
        self.assertEqual(
            None,
            database_operations.convert_values(None, DateField())
        )
        self.assertEqual(
            None,
            database_operations.convert_values(None, DateTimeField())
        )
        self.assertEqual(
            None,
            database_operations.convert_values(None, DecimalField())
        )
        self.assertEqual(
            None,
            database_operations.convert_values(None, IntegerField())
        )
        self.assertEqual(
            None,
            database_operations.convert_values(None, TimeField())
        )
Пример #5
0
 def test_convert_values_to_handle_null_value(self):
     from django.db.backends.sqlite3.base import DatabaseOperations
     convert_values = DatabaseOperations(connection).convert_values
     self.assertIsNone(convert_values(None, AutoField(primary_key=True)))
     self.assertIsNone(convert_values(None, DateField()))
     self.assertIsNone(convert_values(None, DateTimeField()))
     self.assertIsNone(convert_values(None, DecimalField()))
     self.assertIsNone(convert_values(None, IntegerField()))
     self.assertIsNone(convert_values(None, TimeField()))
Пример #6
0
from django.db.backends.sqlite3.base import DatabaseOperations

quote_name = DatabaseOperations().quote_name


def get_table_list(cursor):
    "Returns a list of table names in the current database."
    # Skip the sqlite_sequence system table used for autoincrement key
    # generation.
    cursor.execute("""
        SELECT name FROM sqlite_master
        WHERE type='table' AND NOT name='sqlite_sequence'
        ORDER BY name""")
    return [row[0] for row in cursor.fetchall()]


def get_table_description(cursor, table_name):
    "Returns a description of the table, with the DB-API cursor.description interface."
    return [(info['name'], info['type'], None, None, None, None,
             info['null_ok']) for info in _table_info(cursor, table_name)]


def get_relations(cursor, table_name):
    raise NotImplementedError


def get_indexes(cursor, table_name):
    """
    Returns a dictionary of fieldname -> infodict for the given table,
    where each infodict is in the format:
        {'primary_key': boolean representing whether it's the primary key,