Exemplo n.º 1
0
class NullableFields(models.Model):
    # Fields in db.backends.oracle.BulkInsertMapper
    big_int_filed = models.BigIntegerField(null=True, default=1)
    binary_field = models.BinaryField(null=True, default=b'data')
    date_field = models.DateField(null=True, default=timezone.now)
    datetime_field = models.DateTimeField(null=True, default=timezone.now)
    decimal_field = models.DecimalField(null=True, max_digits=2, decimal_places=1, default=Decimal('1.1'))
    duration_field = models.DurationField(null=True, default=datetime.timedelta(1))
    float_field = models.FloatField(null=True, default=3.2)
    integer_field = models.IntegerField(null=True, default=2)
    null_boolean_field = models.BooleanField(null=True, default=False)
    null_boolean_field_old = models.NullBooleanField(null=True, default=False)
    positive_integer_field = models.PositiveIntegerField(null=True, default=3)
    positive_small_integer_field = models.PositiveSmallIntegerField(null=True, default=4)
    small_integer_field = models.SmallIntegerField(null=True, default=5)
    time_field = models.TimeField(null=True, default=timezone.now)
    # Fields not required in BulkInsertMapper
    char_field = models.CharField(null=True, max_length=4, default='char')
    email_field = models.EmailField(null=True, default='*****@*****.**')
    file_field = models.FileField(null=True, default='file.txt')
    file_path_field = models.FilePathField(path='/tmp', null=True, default='file.txt')
    generic_ip_address_field = models.GenericIPAddressField(null=True, default='127.0.0.1')
    if Image:
        image_field = models.ImageField(null=True, default='image.jpg')
    slug_field = models.SlugField(null=True, default='slug')
    text_field = models.TextField(null=True, default='text')
    url_field = models.URLField(null=True, default='/')
    uuid_field = models.UUIDField(null=True, default=uuid.uuid4)
Exemplo n.º 2
0
class RangeLookupsModel(PostgreSQLModel):
    parent = models.ForeignKey(RangesModel, models.SET_NULL, blank=True, null=True)
    integer = models.IntegerField(blank=True, null=True)
    big_integer = models.BigIntegerField(blank=True, null=True)
    float = models.FloatField(blank=True, null=True)
    timestamp = models.DateTimeField(blank=True, null=True)
    date = models.DateField(blank=True, null=True)
Exemplo n.º 3
0
class VerboseNameField(models.Model):
    id = models.AutoField("verbose pk", primary_key=True)
    field1 = models.BigIntegerField("verbose field1")
    field2 = models.BooleanField("verbose field2", default=False)
    field3 = models.CharField("verbose field3", max_length=10)
    field4 = models.DateField("verbose field4")
    field5 = models.DateTimeField("verbose field5")
    field6 = models.DecimalField("verbose field6",
                                 max_digits=6,
                                 decimal_places=1)
    field7 = models.EmailField("verbose field7")
    field8 = models.FileField("verbose field8", upload_to="unused")
    field9 = models.FilePathField("verbose field9")
    field10 = models.FloatField("verbose field10")
    # Don't want to depend on Pillow in this test
    # field_image = models.ImageField("verbose field")
    field11 = models.IntegerField("verbose field11")
    field12 = models.GenericIPAddressField("verbose field12", protocol="ipv4")
    field13 = models.NullBooleanField("verbose field13")
    field14 = models.PositiveIntegerField("verbose field14")
    field15 = models.PositiveSmallIntegerField("verbose field15")
    field16 = models.SlugField("verbose field16")
    field17 = models.SmallIntegerField("verbose field17")
    field18 = models.TextField("verbose field18")
    field19 = models.TimeField("verbose field19")
    field20 = models.URLField("verbose field20")
    field21 = models.UUIDField("verbose field21")
    field22 = models.DurationField("verbose field22")
Exemplo n.º 4
0
class Reporter(models.Model):
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)
    email = models.EmailField()
    facebook_user_id = models.BigIntegerField(null=True)
    raw_data = models.BinaryField(null=True)
    small_int = models.SmallIntegerField()

    class Meta:
        unique_together = ('first_name', 'last_name')

    def __str__(self):
        return "%s %s" % (self.first_name, self.last_name)
Exemplo n.º 5
0
class AllFieldsModel(models.Model):
    big_integer = models.BigIntegerField()
    binary = models.BinaryField()
    boolean = models.BooleanField(default=False)
    char = models.CharField(max_length=10)
    date = models.DateField()
    datetime = models.DateTimeField()
    decimal = models.DecimalField(decimal_places=2, max_digits=2)
    duration = models.DurationField()
    email = models.EmailField()
    file_path = models.FilePathField()
    floatf = models.FloatField()
    integer = models.IntegerField()
    generic_ip = models.GenericIPAddressField()
    null_boolean = models.NullBooleanField()
    positive_integer = models.PositiveIntegerField()
    positive_small_integer = models.PositiveSmallIntegerField()
    slug = models.SlugField()
    small_integer = models.SmallIntegerField()
    text = models.TextField()
    time = models.TimeField()
    url = models.URLField()
    uuid = models.UUIDField()

    fo = ForeignObject('self',
                       on_delete=models.CASCADE,
                       from_fields=['abstract_non_concrete_id'],
                       to_fields=['id'],
                       related_name='reverse')
    fk = ForeignKey('self', models.CASCADE, related_name='reverse2')
    m2m = ManyToManyField('self')
    oto = OneToOneField('self', models.CASCADE)

    object_id = models.PositiveIntegerField()
    content_type = models.ForeignKey(ContentType, models.CASCADE)
    gfk = GenericForeignKey()
    gr = GenericRelation(DataModel)
Exemplo n.º 6
0
class ColumnTypes(models.Model):
    id = models.AutoField(primary_key=True)
    big_int_field = models.BigIntegerField()
    bool_field = models.BooleanField(default=False)
    null_bool_field = models.BooleanField(null=True)
    char_field = models.CharField(max_length=10)
    null_char_field = models.CharField(max_length=10, blank=True, null=True)
    date_field = models.DateField()
    date_time_field = models.DateTimeField()
    decimal_field = models.DecimalField(max_digits=6, decimal_places=1)
    email_field = models.EmailField()
    file_field = models.FileField(upload_to="unused")
    file_path_field = models.FilePathField()
    float_field = models.FloatField()
    int_field = models.IntegerField()
    gen_ip_address_field = models.GenericIPAddressField(protocol="ipv4")
    pos_int_field = models.PositiveIntegerField()
    pos_small_int_field = models.PositiveSmallIntegerField()
    slug_field = models.SlugField()
    small_int_field = models.SmallIntegerField()
    text_field = models.TextField()
    time_field = models.TimeField()
    url_field = models.URLField()
    uuid_field = models.UUIDField()
Exemplo n.º 7
0
class CaseTestModel(models.Model):
    integer = models.IntegerField()
    integer2 = models.IntegerField(null=True)
    string = models.CharField(max_length=100, default='')

    big_integer = models.BigIntegerField(null=True)
    binary = models.BinaryField(default=b'')
    boolean = models.BooleanField(default=False)
    date = models.DateField(null=True, db_column='date_field')
    date_time = models.DateTimeField(null=True)
    decimal = models.DecimalField(max_digits=2,
                                  decimal_places=1,
                                  null=True,
                                  db_column='decimal_field')
    duration = models.DurationField(null=True)
    email = models.EmailField(default='')
    file = models.FileField(null=True, db_column='file_field')
    file_path = models.FilePathField(null=True)
    float = models.FloatField(null=True, db_column='float_field')
    if Image:
        image = models.ImageField(null=True)
    generic_ip_address = models.GenericIPAddressField(null=True)
    null_boolean = models.BooleanField(null=True)
    null_boolean_old = models.NullBooleanField()
    positive_integer = models.PositiveIntegerField(null=True)
    positive_small_integer = models.PositiveSmallIntegerField(null=True)
    slug = models.SlugField(default='')
    small_integer = models.SmallIntegerField(null=True)
    text = models.TextField(default='')
    time = models.TimeField(null=True, db_column='time_field')
    url = models.URLField(default='')
    uuid = models.UUIDField(null=True)
    fk = models.ForeignKey('self', models.CASCADE, null=True)

    def __str__(self):
        return "%i, %s" % (self.integer, self.string)
Exemplo n.º 8
0
class IntegerModel(models.Model):
    big = models.BigIntegerField(null=True, blank=True)
    normal = models.IntegerField(null=True, blank=True)
    small = models.SmallIntegerField(null=True, blank=True)
Exemplo n.º 9
0
class Migration(migrations.Migration):

    dependencies = [
        ('postgres_tests', '0001_setup_extensions'),
    ]

    operations = [
        migrations.CreateModel(
            name='CharArrayModel',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('field', ArrayField(models.CharField(max_length=10),
                                     size=None)),
            ],
            options={
                'required_db_vendor': 'postgresql',
            },
            bases=(models.Model, ),
        ),
        migrations.CreateModel(
            name='DateTimeArrayModel',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('datetimes', ArrayField(models.DateTimeField(), size=None)),
                ('dates', ArrayField(models.DateField(), size=None)),
                ('times', ArrayField(models.TimeField(), size=None)),
            ],
            options={
                'required_db_vendor': 'postgresql',
            },
            bases=(models.Model, ),
        ),
        migrations.CreateModel(
            name='HStoreModel',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('field', HStoreField(blank=True, null=True)),
                ('array_field', ArrayField(HStoreField(), null=True)),
            ],
            options={
                'required_db_vendor': 'postgresql',
            },
            bases=(models.Model, ),
        ),
        migrations.CreateModel(
            name='OtherTypesArrayModel',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('ips', ArrayField(models.GenericIPAddressField(), size=None)),
                ('uuids', ArrayField(models.UUIDField(), size=None)),
                ('decimals',
                 ArrayField(models.DecimalField(max_digits=5,
                                                decimal_places=2),
                            size=None)),
                ('tags',
                 ArrayField(TagField(), blank=True, null=True, size=None)),
                ('json', ArrayField(JSONField(default={}), default=[])),
                ('int_ranges',
                 ArrayField(IntegerRangeField(), null=True, blank=True)),
                ('bigint_ranges',
                 ArrayField(BigIntegerRangeField(), null=True, blank=True)),
            ],
            options={
                'required_db_vendor': 'postgresql',
            },
            bases=(models.Model, ),
        ),
        migrations.CreateModel(
            name='IntegerArrayModel',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('field', ArrayField(models.IntegerField(), size=None)),
            ],
            options={
                'required_db_vendor': 'postgresql',
            },
            bases=(models.Model, ),
        ),
        migrations.CreateModel(
            name='NestedIntegerArrayModel',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('field',
                 ArrayField(ArrayField(models.IntegerField(), size=None),
                            size=None)),
            ],
            options={
                'required_db_vendor': 'postgresql',
            },
            bases=(models.Model, ),
        ),
        migrations.CreateModel(
            name='NullableIntegerArrayModel',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('field',
                 ArrayField(models.IntegerField(),
                            size=None,
                            null=True,
                            blank=True)),
            ],
            options={
                'required_db_vendor': 'postgresql',
            },
            bases=(models.Model, ),
        ),
        migrations.CreateModel(
            name='CharFieldModel',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('field', models.CharField(max_length=16)),
            ],
            options=None,
            bases=None,
        ),
        migrations.CreateModel(
            name='TextFieldModel',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('field', models.TextField()),
            ],
            options=None,
            bases=None,
        ),
        migrations.CreateModel(
            name='Scene',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('scene', models.CharField(max_length=255)),
                ('setting', models.CharField(max_length=255)),
            ],
            options=None,
            bases=None,
        ),
        migrations.CreateModel(
            name='Character',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('name', models.CharField(max_length=255)),
            ],
            options=None,
            bases=None,
        ),
        migrations.CreateModel(
            name='CITestModel',
            fields=[
                ('name', CICharField(primary_key=True, max_length=255)),
                ('email', CIEmailField()),
                ('description', CITextField()),
                ('array_field', ArrayField(CITextField(), null=True)),
            ],
            options={
                'required_db_vendor': 'postgresql',
            },
            bases=None,
        ),
        migrations.CreateModel(
            name='Line',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('scene',
                 models.ForeignKey('postgres_tests.Scene',
                                   on_delete=models.SET_NULL)),
                ('character',
                 models.ForeignKey('postgres_tests.Character',
                                   on_delete=models.SET_NULL)),
                ('dialogue', models.TextField(blank=True, null=True)),
                ('dialogue_search_vector',
                 SearchVectorField(blank=True, null=True)),
                ('dialogue_config',
                 models.CharField(max_length=100, blank=True, null=True)),
            ],
            options={
                'required_db_vendor': 'postgresql',
            },
            bases=None,
        ),
        migrations.CreateModel(name='AggregateTestModel',
                               fields=[
                                   ('id',
                                    models.AutoField(verbose_name='ID',
                                                     serialize=False,
                                                     auto_created=True,
                                                     primary_key=True)),
                                   ('boolean_field',
                                    models.BooleanField(null=True)),
                                   ('char_field',
                                    models.CharField(max_length=30,
                                                     blank=True)),
                                   ('integer_field',
                                    models.IntegerField(null=True)),
                               ]),
        migrations.CreateModel(name='StatTestModel',
                               fields=[
                                   ('id',
                                    models.AutoField(verbose_name='ID',
                                                     serialize=False,
                                                     auto_created=True,
                                                     primary_key=True)),
                                   ('int1', models.IntegerField()),
                                   ('int2', models.IntegerField()),
                                   ('related_field',
                                    models.ForeignKey(
                                        'postgres_tests.AggregateTestModel',
                                        models.SET_NULL,
                                        null=True,
                                    )),
                               ]),
        migrations.CreateModel(name='NowTestModel',
                               fields=[
                                   ('id',
                                    models.AutoField(verbose_name='ID',
                                                     serialize=False,
                                                     auto_created=True,
                                                     primary_key=True)),
                                   ('when',
                                    models.DateTimeField(null=True,
                                                         default=None)),
                               ]),
        migrations.CreateModel(name='UUIDTestModel',
                               fields=[
                                   ('id',
                                    models.AutoField(verbose_name='ID',
                                                     serialize=False,
                                                     auto_created=True,
                                                     primary_key=True)),
                                   ('uuid',
                                    models.UUIDField(default=None, null=True)),
                               ]),
        migrations.CreateModel(
            name='RangesModel',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('ints', IntegerRangeField(null=True,
                                           blank=True)),
                ('bigints', BigIntegerRangeField(null=True, blank=True)),
                ('floats', FloatRangeField(null=True, blank=True)),
                ('timestamps', DateTimeRangeField(null=True, blank=True)),
                ('dates', DateRangeField(null=True, blank=True)),
            ],
            options={'required_db_vendor': 'postgresql'},
            bases=(models.Model, )),
        migrations.CreateModel(
            name='RangeLookupsModel',
            fields=[
                ('parent',
                 models.ForeignKey(
                     'postgres_tests.RangesModel',
                     models.SET_NULL,
                     blank=True,
                     null=True,
                 )),
                ('integer', models.IntegerField(blank=True, null=True)),
                ('big_integer', models.BigIntegerField(blank=True, null=True)),
                ('float', models.FloatField(blank=True, null=True)),
                ('timestamp', models.DateTimeField(blank=True, null=True)),
                ('date', models.DateField(blank=True, null=True)),
            ],
            options={
                'required_db_vendor': 'postgresql',
            },
            bases=(models.Model, ),
        ),
        migrations.CreateModel(
            name='JSONModel',
            fields=[
                ('id',
                 models.AutoField(verbose_name='ID',
                                  serialize=False,
                                  auto_created=True,
                                  primary_key=True)),
                ('field', JSONField(null=True, blank=True)),
                ('field_custom',
                 JSONField(null=True, blank=True, encoder=DjangoJSONEncoder)),
            ],
            options={
                'required_db_vendor': 'postgresql',
            },
            bases=(models.Model, ),
        ),
    ]
Exemplo n.º 10
0
class BigInt(models.Model):
    biggie = models.BigIntegerField()

    def __str__(self):
        return str(self.biggie)
Exemplo n.º 11
0
class BigIntegerData(models.Model):
    data = models.BigIntegerField(null=True)
Exemplo n.º 12
0
 def test_big_integer_field(self):
     field = models.BigIntegerField()
     name, path, args, kwargs = field.deconstruct()
     self.assertEqual(path, "djmodels.db.models.BigIntegerField")
     self.assertEqual(args, [])
     self.assertEqual(kwargs, {})
Exemplo n.º 13
0
class BigIntegerModel(models.Model):
    value = models.BigIntegerField()
    null_value = models.BigIntegerField(null=True, blank=True)
Exemplo n.º 14
0
class Number(models.Model):
    integer = models.BigIntegerField(db_column='the_integer')
    float = models.FloatField(null=True, db_column='the_float')

    def __str__(self):
        return '%i, %.3f' % (self.integer, self.float)