question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No such column error

See original GitHub issue

I’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:open
  • Created 9 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
sibeliuscommented, Nov 24, 2015

maybe we should rethink how Sugar creates or transform collums names

1reaction
agustinm20commented, Jan 9, 2015

On the public class change this: public TripGroup tripGroup;

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found