Hi,

given this legacy informix table:
~~~~~~~~~~~~~~~~~~~~~~~
create table kperson
(
  name  varchar(80, 1) not NULL,
  age   integer not NULL,
  primary key (name)
);

I did:
~~~~
>>> db.define_table("kperson",
...     Field("name"),
...     Field("age"),
...     primarykey=["name"],
...     migrate=False
... )

Inserting one row:
~~~~~~~~~~~~~
>>> db.kperson.insert(name="Oli1", age=23)
{'name': 'Oli1'}

Ok!

inserting another row:
~~~~~~~~~~~~~~~~
>>> db.kperson.insert(name="Oli2", age=23)
{'name': 'Oli2'}

Ok!

trying to update the first row:
~~~~~~~~~~~~~~~~~~~~~
>>> db(db.kperson.name=="Oli1").update(name="Oli2")
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/root/web2py-1439/gluon/sql.py", line 3091, in update
    self._db._execute(query)
  File "/root/web2py-1439/gluon/sql.py", line 1086, in <lambda>
    self._execute = lambda a: self._cursor.execute(a[:-1])
IntegrityError: SQLCODE -268 in EXECUTE:
23000: Integrity constraint violation
IX000: ISAM error:  duplicate value for a record with unique key.

Ok, this IntegrityError was expected, because we tried to update name
to a value that already existed in the table.

But trying to insert a row with an already existing name:

>>> db.kperson.insert(name="Oli2", age=23)

does not give an error message at all - although the same constraint
violation occurs!?

Why is there no IntegrityError exception raised in this case? Same
strange behavior with appadmin: you can 'insert' new rows with
appadmin that violate constraints and therefore are not really
inserted into the table without even getting an error message. I don't
think that this behavior is consistent.

Regards

  Hans
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to