-
Notifications
You must be signed in to change notification settings - Fork 583
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
No such table exceptions #75
Comments
Try to increment your database version in the manifest file. That might work. |
I am getting this issue too |
Can you check with your configuration if they're fine. Another thing is: With 1.2 you need to have a constructor with Context parameter. If it still doesn't work, please post your configuration and one of your entity classes. thanks. |
Hi Satyan, I am using 1.3 beta now. I can see how SugarDb.getDomainClass(String, Context) was failing to get any children of SugarRecord. It's not well documented that devs need to create empty constructors in their classes that extend from SugarRecord. The readme or the main website documentation should be updated. v 1.2 was such a joy to use but going v1.3 was very frustrating. This line is the culprit:
It fails to create an instance of a class that extends from SugarRecord if that class should have at least one constructor that has 1 or more parameters. It would be ideal that we didn't have to define boilerplate empty constructors but I'm not quite sure if it's possible v 1.3 and onward. The reason why is I think most of us define our Entities with convenience constructors like:
As soon as we create a constructor like this, the default empty one is not automatically created. Also, there is no guarantee a developer will create only one constructor as he/she could create many. Wishful thinking would be to invoke the superclass's constructor (SugarRecord's) when the problem line is run but that doesn't work as I've experimented. |
I think this is necessary.
Specify a package name where your domain/entity classes are present. This helps in smoother table creation. |
I'm having the same issue. public class Router extends SugarRecord
} this is my AndroidManifest.xml:
Any ideas? thanks, |
Hey @skunkwerk, I tried your code and it works just fine. Are you certain that your Also, if you've previously created a database with that class in another form (different class name or different set of member fields), then you'll have to do an explicit migration to alter the database table, or delete the database table and let Sugar ORM create another one for you. Let me know if you need help with any of these things. |
I have the same error on my device (Nexus 5), either on allList():
or on save():
but the weird thing is that it does not occur on the emulator... An idea what I could do to fix this? |
Ok, after having deleted application data, it works well. |
Create a empty constructor if you created one with arguments. Works to me after I cleared cache of app. |
I tried it all still the same error -_- |
What error @exadeci ? And please paste you class too. |
@idemax The error was "No such table" but I created a new package for my models and it worked :) |
incrementing my database version in the manifest file work for me, also making a public constructor with no parameters. |
I got the same problem. I already following the "getting started" guide.. after searching for answer, I figured it by putting my package name of my classes of SugarRecord on "DOMAIN_PACKAGE_NAME" |
Please show what creating the constructor would look like |
I believe many of these issues are a result of outdated documentation. When 1.4.0 is released, I'll be sure to update http://satyan.github.io/sugar to be as up to date and thorough as possible. |
I was having this error and i uninstalled my application and cleared cache and everything worked well . |
the "no such table" error was solved for me when I correctly set the "DOMAIN_PACKAGE_NAME" meta data in AndroidManifest.xml |
I had the same issue on Sugar v1.3. [...] |
If you are using For example, if you have a table called |
Does it make sence to throw an exception if SugarRecord<> successor doesn't have a default constructor? |
@fanadd I believe it does since SugarORM tries to instantiate it using reflection. It's not a code generator ORM. |
I still have this error (non such table) with 1.4 and the documentation is still very much outdated. tried all of the above (version number, domain package name, clearing cache/deleting app) nothing worked |
@dnano91 tried the empty constructor thing? see my comment above |
Yes, had an empty constructor anyway. That's why I forgot to mention it
|
I had the same error. It was caused by a wrong definition of the package name in the manifest file. I configured the root package of the app and not the package containing the model classes. |
I had the same error. I was using |
@moyheen try to change database version from n to n+1 (for ex.) |
When using Android Studio with Instant Run see issue #542 |
Instant Run now works #564 |
I am getting same exception on my MotoG3- Marshmallow. |
@shashi2459 if you use Android Studio it's because InstantRun generates own .dex files that Sugar don't take care, so when trying to deploy the app using InstantRun you don't get the tables generated. |
Yes im using Android Studio....But the same code runs on Kitkat tablet with and without INSTANT RUN |
Sugar takes care when Android Studio uses InstantRun, this pull #564 fix this |
@sibeliusseraphini I refer to Sugar v1.5 not to the master branch. |
@sibeliusseraphini I already tried v1.5 and the issue continues. |
@shashi2459 the PR is in the master branch. Just configure your project to use the master and it will work. |
@sibeliusseraphini how and where to configure it for Android Studio and Gradle? |
@shashi2459 there is some instructions of using the master version with your project on README |
Had the same problem - turned out to be a problem with instant-run. To disable Instant Run: |
The suggestion of changing ExampleTable to example_Table in a findWithQuery suggested by @moyheen worked for me. This is not terribly encouraging since it was working with EXAMPLE_TABLE before I upgraded Android Studio to 2.0 and SDK to 23.0.3, Sugar ORM from 1.3 to (tried 1.4 and now on 1.5, both of which didn't work with the old table names). |
I switch InstantRun off when I know Sugar has to create/modify tables. After the table DDL actions you can enable InstantRun again. |
Please, add instant run patches to release version - on new Android studio any demos not working without it. |
@truefedex you can use master version, just follow readme instructions |
Hi, it is not working for me using "com.github.satyan:sugar:1.4". |
Not working using compile 'com.github.satyan:sugar:1.4' public class Data extends SugarRecord {
|
If you're using 1.5, I've found that I have to give the library a bit of a kick to get it started. If you do
and you don't see something like this:
Then try modifying your onCreate() in your App to look like this:
Suboptimal, but I found that this forces the database tables to be created (once you are sure you have all the required constructors/annotations setup right). One potential improvement to the logging would be logging verification failures: i.e. whenever the ReflectionUtil retrieves a class that SHOULD be a candidate but fails it because it is missing an annotation or a required constructor make that an explicit log statement. |
Even though I've explicitly called the .save() method on my subclass of SugarRecord (Exercise) when the database is created I'm getting errors when querying and there's no such table exceptions associated with the class.
The text was updated successfully, but these errors were encountered: