Open evoshawkins opened 7 months ago
I'm having exactly the same issue here, any solution?
Sorry for my English. I managed to find a very simple solution to work around the bug. I executed the command --file="./migration.sql"
to create the tables normally, but to create the trigger I used the command --command="CODE_SQL"
.
The final result looks like this:
wrangler d1 execute name_d1 --file=./migration.sql
wrangler d1 execute name_d1 --command="CREATE TRIGGER name_trigger AFTER UPDATE ON name_table BEGIN UPDATE name_table SET updated_at = CURRENT_TIMESTAMP WHERE user_id = NEW.user_id; END;"
This way it worked as expected. In the future, they should fix this bug. For now, this is the only solution I found.
I can confirm that your work-around works. Well done! @rafaelsg-01
There is, of course, still a bug for CF to fix here.
Another work-around that works: put the code for the trigger in your migration file on a single line.
❌ Before:
CREATE TRIGGER IF NOT EXISTS food_ai
AFTER INSERT
ON food
BEGIN
INSERT INTO food_search(rowid, brand, flavor) VALUES (new.id, new.brand, new.flavor);
END;
✅ After:
CREATE TRIGGER IF NOT EXISTS food_ai AFTER INSERT ON food BEGIN INSERT INTO food_search(rowid, brand, flavor) VALUES (new.id, new.brand, new.flavor); END;
Which Cloudflare product(s) does this pertain to?
D1
What version(s) of the tool(s) are you using?
3.28.1 [Wrangler]
What version of Node are you using?
v18.17.0
What operating system and version are you using?
Windows 10 Enterprise
Describe the Bug
Observed behavior
The attached SQL works without error on local D1
wrangler d1 execute gateway --local --file=./developer.txt
But fails with error 'incomplete input [code: 7500]' on cloud D1.
wrangler d1 execute gateway --file=./developer.txt
After removing the trigger clause and executing again, the error is gone and the command completes.
Expected behavior
The SQL should work without error on the cloud/non-local D1 database.
developer.txt
Steps to reproduce
Having a workers project with a D1 binding, only the wrangler CLI is need to reproduce.
wrangler d1 execute gateway --local --file=./developer.txt
wrangler d1 execute gateway --file=./developer.txt
Please provide a link to a minimal reproduction
No response
Please provide any relevant error logs
[ERROR] A request to the Cloudflare API (/accounts/19d8630770d1a38b0ed6e6d0f6fa54b9/d1/database/63dfffdd-1c19-412e-be20-6a789d4f6c71/query) failed.
incomplete input [code: 7500]