1 |
|
---|
2 | # insert into your DB
|
---|
3 | cat test_case.sql | sqlite3 test.db
|
---|
4 | cat test_case.mysql.sql | mysql -u test test
|
---|
5 | cat test_case.psql.sql | psql -U test test
|
---|
6 |
|
---|
7 | ## the command for postgresql will fail, as '0000-00-00' is not a valid
|
---|
8 | ## data in postgresql.. As such the rest of this testcase is not applicable.
|
---|
9 |
|
---|
10 | # create app for legacy tables
|
---|
11 | ./manage.py startapp testcase
|
---|
12 |
|
---|
13 | # run inspectdb
|
---|
14 | ./manage.py inspectdb > testcase/models.py
|
---|
15 |
|
---|
16 | # modify models.py (set primary key for instance)
|
---|
17 | $EDITOR testcase/models.py
|
---|
18 |
|
---|
19 | # run syncdb
|
---|
20 | ./manage.py syncdb
|
---|
21 |
|
---|
22 | # run dumpdata
|
---|
23 | ./manage.py dumpdata testcase
|
---|
24 |
|
---|
25 | ## For sqlite3 this yields:
|
---|
26 | File "/usr/lib/python2.4/site-packages/django/db/backends/util.py", line 49, in typecast_date
|
---|
27 | return s and datetime.date(*map(int, s.split('-'))) or None # returns None if s is null
|
---|
28 | ValueError: year is out of range
|
---|
29 |
|
---|
30 | # cannot run loaddata for sqlite3 as it failed saving the fixture.
|
---|
31 | # datetime cannot use '0000' as a year field.
|
---|
32 |
|
---|
33 | ## For mysql this yields:
|
---|
34 | ...
|
---|
35 | {
|
---|
36 | "pk": 2,
|
---|
37 | "model": "testcase.testcase",
|
---|
38 | "fields": {
|
---|
39 | "date": null,
|
---|
40 | "header": "test case 2"
|
---|
41 | }
|
---|
42 | },
|
---|
43 | ...
|
---|
44 |
|
---|
45 | # run loaddata
|
---|
46 | ./manage.py loaddata test_dump.json
|
---|
47 | Installing json fixture 'xxx' from absolute path.
|
---|
48 | Problem installing fixture 'xxx.json': Column 'Date' cannot be null
|
---|
49 |
|
---|
50 | ## For postgresql this yields:
|
---|
51 | Error: Unable to serialize database: year=1 is before 1900; the datetime strftime() methods require year >= 1900
|
---|
52 |
|
---|