maxtepkeev / architect

A set of tools which enhances ORMs written in Python with more features
Other
391 stars 57 forks source link

ProgrammingError: Invalid type name #28

Closed jared-mackey closed 8 years ago

jared-mackey commented 8 years ago

I am getting the following traceback when trying to setup my tables to include partitioning on postgres.

Traceback (most recent call last):
  File "/lib/python3.5/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
psycopg2.ProgrammingError: invalid type name "stats_repstat.date%TYPE"
LINE 6:                     match stats_repstat.date%TYPE;
                                  ^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/bin/architect", line 11, in <module>
    sys.exit(main())
  File "/lib/python3.5/site-packages/architect/commands/__init__.py", line 93, in main
    commands[command]['parser'].result(args.func(vars(args)))
  File "/lib/python3.5/site-packages/architect/commands/partition.py", line 32, in run
    cls.architect.partition.get_partition().prepare()
  File "/lib/python3.5/site-packages/architect/databases/postgresql/partition.py", line 107, in prepare
    column=self.column_name
  File "/lib/python3.5/site-packages/architect/orms/django/features.py", line 44, in execute
    return self.connection.execute(sql)
  File "/lib/python3.5/site-packages/django/db/backends/utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/lib/python3.5/site-packages/django/db/utils.py", line 95, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/lib/python3.5/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
django.db.utils.ProgrammingError: invalid type name "stats_repstat.date%TYPE"
LINE 6:                     match stats_repstat.date%TYPE;
                                  ^
architect==0.5.3
psycopg2==2.6.1
Django==1.9.7
                                           version
-----------------------------------------------------------------------------------------------
 PostgreSQL 9.4.8 on x86_64-unknown-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit
(1 row)
jared-mackey commented 8 years ago

My apologies, this was a complex inheritance issue with the models and not an issue with architect. Took much longer to realize this than it should have.

maxtepkeev commented 8 years ago

No problem, glad you figured it out.

martarozek commented 7 years ago

@mackeyja92 could you tell more about how you solved the problem? My model is inheriting from the Django's AbstractUser and I want to partition by id. I'm getting the same error.