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

Unable to insert into new table. (Unhandled Exception: InvalidDataException) #38

Closed
efortuna opened this issue Jun 16, 2019 · 1 comment

Comments

@efortuna
Copy link

efortuna commented Jun 16, 2019

I used exactly the demo code example described in "Getting Started" (https://moor.simonbinder.eu/getting-started/) and then "inserting" here:

https://moor.simonbinder.eu/queries/

Future<int> addTodoEntry(Todo entry) {
  return into(todos).insert(entry);
}

myDatabaseObject.addTodoEntry(
  Todo(
    title: 'Important task',
    content: 'Refactor persistence code',
  ),
);

And then I get the following error:

[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: InvalidDataException: Invalid data: Todo(id: null, title: Important task, content: Refactor persistence code, category: null) cannot be written into todos
#0 InsertStatement._validateIntegrity
package:moor/…/statements/insert.dart:120
#1 InsertStatement.insert
package:moor/…/statements/insert.dart:30

#2 MyDatabase.addTodoEntry
package:hn_app/favorites.dart:58
#3 _Item.build..
package:hn_app/main.dart:199
#4 _InkResponseState._handleTap
package:flutter/…/material/ink_well.dart:511
#5 _InkResponseState.build.
package:flutter/…/material/ink_well.dart:566
#6 GestureRecognizer.invokeCallback
package:flutter/…/gestures/recognizer.dart:166
#7 TapGestureRecognizer._checkUp
package:flutter/…/gestures/tap.dart:240
#8 TapGestureRecognizer.acceptGesture (package:flutte<…>

This is with Moor v 1.4.0.

@simolus3
Copy link
Owner

Thank you for reporting this, this was an inconsistency in the documentation that I've now fixed (the maximum length of Todos.title was too short).
I'll also try to implement some mechanism to provide more helpful error messages when that happens.

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

2 participants