Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E/SQLiteLog: (1555) abort at 25 #134

Open
nikolamin opened this issue Oct 19, 2020 · 0 comments
Open

E/SQLiteLog: (1555) abort at 25 #134

nikolamin opened this issue Oct 19, 2020 · 0 comments

Comments

@nikolamin
Copy link

nikolamin commented Oct 19, 2020

I am getting this error with SQLite from io.requery:sqlite-android:3.33.0 but everything works fine with the android framework SQLite. Can you help me understand what's the issue or possibly investigate the issue with requery sqlite?

Here is the setup:

CREATE TABLE `ProductItem` (`productId` INTEGER NOT NULL, `itemId` INTEGER NOT NULL, 
PRIMARY KEY(`posId`, `productionDepartmentId`), 
FOREIGN KEY(`productId`) REFERENCES `Product`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, 
FOREIGN KEY(`itemId`) REFERENCES `Item`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )
CREATE TABLE `_UpdateTime` (`id` INTEGER NOT NULL,`field` INTEGER NOT NULL,`time` INTEGER NOT NULL DEFAULT (CAST((julianday('now') - 2440587.5)*86400000000 AS INTEGER)),`modifier` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`id`,`field`))
CREATE TRIGGER tracking_ProductItem_on_insert AFTER INSERT ON `ProductItem` FOR EACH ROW BEGIN
   INSERT OR REPLACE INTO `_UpdateTime` (`id`, `field`) VALUES (NEW.ROWID, 6900);
END

Query:

INSERT INTO `ProductItem` (`productId`, `itemId`) VALUES (2, 1)

Error:

E/SQLiteLog: (1555) abort at 25 in [INSERT OR ABORT  INTO ProductItem(`productId`,`itemId`) VALUES (?,?)]: UNIQUE constraint failed: _UpdateTime.id, _UpdateTime.field

As you can see from the error message, the error occurs in the trigger, and the error suggests that a record with the same composite key exists (productId, itemId) - (2,1), but this should not happen on INSERT OR REPLACE. Actually, this doesn't happen on other sqlite builds i have tried (framework sqlite and some other custom builds), and doesn't happen all the time.
As i noticed the issue appears when the record is inserted, deleted, and inserted again.

When i pull the database from the Android device after the error appeared and try to open with DB Browser for SQLite or sqlite 3.33 , the query executes successfully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant