lbehnke / h2database

Automatically exported from code.google.com/p/h2database
0 stars 0 forks source link

web console edit/insert row failed on table with uuid primary key #162

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
(simple SQL scripts or simple standalone applications are preferred)
1.
CREATE CACHED TABLE PUBLIC.FOO(
    BAR UUID NOT NULL,
    DATA VARCHAR(10)
);
ALTER TABLE PUBLIC.FOO ADD CONSTRAINT PUBLIC.CONSTRAINT_11 PRIMARY KEY(BAR);
-- 1 +/- SELECT COUNT(*) FROM PUBLIC.FOO;
INSERT INTO PUBLIC.FOO(BAR, DATA) VALUES
('0f573c6e-7a8e-44d8-949d-b58cf276e48a', NULL);

2. SELECT * FROM FOO --in web console
3. try edit or insert in table

What is the expected output? What do you see instead?
edit/insert rows in console

What version of the product are you using? On what operating system, file
system, and virtual machine?
H2 1.2.128 (2010-01-30)
win xp sp2
ntfs
java 1.7.0-ea-b75

Do you know a workaround?
SQuirell SQL Client :D
How important/urgent is the problem for you?
no
In your view, is this a defect or a feature request?
feature
Please provide any additional information below.

Original issue reported on code.google.com by molnar.p...@gmail.com on 3 Feb 2010 at 1:33

GoogleCodeExporter commented 9 years ago
Hi,

Thanks a lot! The root cause of the problem is: There is a bug converting a 
UUID to
binary:

call cast(cast('01020304-0506-0708-090a-0b0c0d0e0f00' as uuid) as binary);

I will fix this for the next release. The correction is in ValueUuid:

public byte[] getBytes() {
    byte[] buff = new byte[16];
    for (int i = 0; i < 8; i++) {
        buff[i] = (byte) ((high >> (8 * (7 - i))) & 255);
        buff[8 + i] = (byte) ((low >> (8 * (7 - i))) & 255);
    }
    return buff;
}

(7 - i instead of 8 - i).

Regards,
Thomas

Original comment by thomas.t...@gmail.com on 7 Feb 2010 at 4:37

GoogleCodeExporter commented 9 years ago
thx, I will try it from svn trunk.:D

Original comment by molnar.p...@gmail.com on 7 Feb 2010 at 9:09

GoogleCodeExporter commented 9 years ago
This should be fixed with version 1.2.129.

Original comment by thomas.t...@gmail.com on 20 Feb 2010 at 9:43