No such column error
See original GitHub issueI’m running into a no such column error in my code that according to the docs shouldn’t be happening. Here’s the tables object definition.
public class TripRow extends SugarRecord<TripRow> {
public String address;
public double distance = 0;
public String units = "km";
//Relationship to a trip_group. Meaning a collection of trips that are logically grouped together.
//I may add additional columns for groups later.
public TripGroup trip_group;
public TripRow(String address, double distance, TripGroup trip_group) {
this.address = address;
this.distance = distance;
this.trip_group = trip_group;
}
public TripRow() {
}
}
When I try to load it with the following statement I get a no such column exception.
String entries[] = {Long.toString(group.getId())};
//List<TripRow> rows = TripRow.listAll(TripRow.class);
List<TripRow> rows = TripRow.find(TripRow.class, "trip_group = ? ", entries, null, " id ASC", null);
Here’s the exception:
Caused by: android.database.sqlite.SQLiteException: no such column: trip_group (code 1): , while compiling: SELECT * FROM TRIP_ROW WHERE trip_group = ? ORDER BY id DESC
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1113)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:690)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1448)
at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1295)
at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1166)
at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1372)
at com.orm.SugarRecord.find(SugarRecord.java:208)
at com.orm.SugarRecord.find(SugarRecord.java:172)
Issue Analytics
- State:
- Created 9 years ago
- Comments:11 (2 by maintainers)
Top Results From Across the Web
No such column when column exists - sqlite
The problem is that even though the column sendok exists, when running a query on the database with that field, it throws an...
Read more >SQLite Exception no such column when trying to select
This works fine when the student id's are ints (346742) but whenever I try to add an alpha-numeric id (PB3874) it force closes...
Read more >Salesforce - Resolve error "No such column 'X' on entity 'X'.
Issue: Endpoint requests using the Salesforce connector fail with: No such column 'Billingstreet' on entity 'Account'.
Read more >SQLite "Error: SQLITE_ERROR: no such column:" - General
Hello, I just try a hunderet times but I can't fix it.. I created a new table: CREATE TABLE 'erfassungsbeleg' ('id' INTEGER PRIMARY...
Read more >DATABASE ERROR - no such column - Tenable Community
I recently upgraded Security Center to 4.8.1 and then 5.2.0 on CentOS. After the upgrade, we've been having some issues. We are able...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
maybe we should rethink how Sugar creates or transform collums names
On the public class change this: public TripGroup tripGroup;