PageRenderTime 26ms CodeModel.GetById 22ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/modeltests/reserved_names/models.py

https://code.google.com/p/mango-py/
Python | 25 lines | 8 code | 0 blank | 17 comment | 0 complexity | b30449c930d85a7253d3bee59b4a6f4c MD5 | raw file
 1"""
 218. Using SQL reserved names
 3
 4Need to use a reserved SQL name as a column name or table name? Need to include
 5a hyphen in a column or table name? No problem. Django quotes names
 6appropriately behind the scenes, so your database won't complain about
 7reserved-name usage.
 8"""
 9
10from django.db import models
11
12class Thing(models.Model):
13    when = models.CharField(max_length=1, primary_key=True)
14    join = models.CharField(max_length=1)
15    like = models.CharField(max_length=1)
16    drop = models.CharField(max_length=1)
17    alter = models.CharField(max_length=1)
18    having = models.CharField(max_length=1)
19    where = models.DateField(max_length=1)
20    has_hyphen = models.CharField(max_length=1, db_column='has-hyphen')
21    class Meta:
22       db_table = 'select'
23
24    def __unicode__(self):
25        return self.when