Problem with rname?

53 views
Skip to first unread message

Johann Spies

unread,
Apr 1, 2014, 4:41:06 AM4/1/14
to web...@googlegroups.com
Database: Postgresql

I get this regularly when I modify a table's definition (tables using rname):

ProgrammingError: relation "org_unit" does not exist

I either set 'migrate = False'  or drop the table, delete the entry in databases and do it over - that is when the table is empty.

I suspect it is a problem with rname.

Here is an example definition (btw the fields with 'text' will be changed to 'citext' in Postgresql)


db.define_table('org_unit',
                Field('name', 'text'),
                Field('city', 'text'),
                Field('post_code', length=14),
                Field('street', 'text'),
                Field('country', 'text'),
                Field('countrycode', length = 2),
                rname = '"level1"."org_unit"',
                migrate = True,
                fake_migrate = False)

Regards
Johann
--
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

Richard Vézina

unread,
Apr 15, 2014, 10:42:28 AM4/15/14
to web2py-users
Hello Johann,

Do you get any advice?

I am in the process to test the rname feature and I don't find much information, it's seems highly experimental and undocumented...


Except maybe this :



Richard

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Richard Vézina

unread,
Apr 15, 2014, 10:52:52 AM4/15/14
to web2py-users
I am not sure what rname does...

Does it do, what it means, so it should contains the real name of the backend table name for instance or the reverse...

I make a test with one of my model, adding rname to the model for the table name and one of the table field and try to make a query and look at it (._select()) and get the rname that I defined as a table name and field.

Richard

Richard Vézina

unread,
Apr 15, 2014, 11:12:05 AM4/15/14
to web2py-users
This is exactly what happen...

Let say I have a table like this one in Postgres :

# Postgres

CREATE TABLE address
(
  id serial NOT NULL,
  door_number character varying,
  street character varying,
  city_id integer,
  CONSTRAINT address_pkey PRIMARY KEY (id )
)
WITH (
  OIDS=FALSE
);
ALTER TABLE address
  OWNER TO richard;

# OLD Models
db.define_table('address',
                Field('door_number', 'string'),
                Field('street', 'string'),
                Field('city_id', 'reference city'),
                )


# NEW Models with rname
db.define_table('Address',
                       Field('Door_Number', 'string', rname='door_number'),
                       Field('Street', 'string', rname='street'),
                       Field('City', 'reference city', rname='city_id'),
                       rname='address'
                       )

Then, I can access value like that :

db(db.Address.Door_Number == '1000').select(db.Address.ALL)

DAL, only know the models names, ex.: Door_Number

You can't not use the backend rname to interract with the backend...

Richard




Johann Spies

unread,
Apr 16, 2014, 2:27:13 AM4/16/14
to web...@googlegroups.com
Hallo Richard,

I use rname to be able to make use of Postgresqll schemas.

e.g. rname = '"level1"."journal"'

In this case when migrate is true, DAL will create a table 'journal'  in the schema 'level1' .  And that is working as expected.  My problem as stated above is only when I then make changes to the definition of 'journal'.

Regards
Johann



Reply all
Reply to author
Forward
0 new messages