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

2:0 swift expression based query returning empty results #1701

Closed
jamiltz opened this Issue Apr 6, 2017 · 7 comments

Comments

Projects
None yet
3 participants
@jamiltz
Contributor

jamiltz commented Apr 6, 2017

The following creates a document and query.

// create database
let database: Database;
do {
    database = try Database(name: "my-database")
} catch let error as NSError {
    return NSLog("Cannot open the database: %@", error);
}
// create document
let document = database.document()
do {
    try document.save()
} catch let error {
    print(error.localizedDescription)
}
// mutability
document.properties = [
    "type": "user",
    "admin": false,
    "address": [
        "street": "1 park street",
        "zip": 123456
    ]
]
do {
    try document.save()
    print("document type :: \(document["type"] as String?)")
} catch let error {
    print(error.localizedDescription)
}

// standalone query
let query = Query
    .select()
    .from(DataSource.database(database))
    .where(
        Expression.property("type").match("user")
            .and(Expression.property("admin").match(false))
    )
do {
    let rows = try query.run()
    for row in rows {
        print("doc ID :: \(row.documentID)")
    }
} catch let error {
    print(error.localizedDescription)
}

On the last method call when the query.run() is called it throws the error message no such table: kv_default::.type to the console. Not sure if the code syntax above is incorrect or if it is a bug. No query index were created in this example.


  • Version: 2.0 DB4
  • Client OS: iOS 10
  • Server: N/A
@pasin

This comment has been minimized.

Contributor

pasin commented Apr 6, 2017

match is for full-text search so I'm not sure if that is the case of not. Can you change from match to equal?

@jamiltz

This comment has been minimized.

Contributor

jamiltz commented Apr 6, 2017

Good catch, that's why it was throwing the error. Updated the example to use equalTo. However the expected results are not returned (i.e rows is empty). Keeping this open and will try again tomorrow.

jamiltz added a commit to couchbaselabs/couchbase-mobile-portal that referenced this issue Apr 6, 2017

@djpongh djpongh added this to the 2.0 DB5 milestone Apr 7, 2017

@djpongh djpongh added ready bug labels Apr 7, 2017

@djpongh djpongh modified the milestones: 2.0 DB6, 2.0 DB5 Apr 14, 2017

@jamiltz jamiltz changed the title from 2:0 swift expression based query throwing error to 2:0 swift expression based query returning empty results May 9, 2017

@jamiltz

This comment has been minimized.

Contributor

jamiltz commented May 9, 2017

@pasin the above example is working fine and the expected results are returned. However, in another query the result is empty again. Here it is:

let query = Query
    .select()
    .from(DataSource.database(database))
    .where(Expression.property("type").equalTo("airline"))

do {
    let rows = try query.run()
    print(rows.underestimatedCount)
    for row in rows {
        print("doc ID :: \(row.documentID)")
    }
} catch let error {
    print(error.localizedDescription)
}

Is the type property treated differently to other properties? The logs don't return anything (0 rows) but I'm sure some document with type: "airline" are present in the database.

@djpongh djpongh modified the milestones: 2.0 DB8, 2.0 DB6 May 12, 2017

@pasin

This comment has been minimized.

Contributor

pasin commented Jun 7, 2017

@jamiltz is this still an issue?

@jamiltz

This comment has been minimized.

Contributor

jamiltz commented Jun 8, 2017

That database with airline, route, airport and landmark documents contained 35 000 docs. Running a replication with 2.0 and then querying the database content resulted in those unexpected empty results. This issue was resolved by replicating the documents to a .cblite2 file with CBL 1.4 and then opening the local database with 2.0 (which automatically upgrades the database to 2.0). There's strong indication that replicating the documents with 2.0 resulted in those empty results. But I don't know how to provide details on that. I'll use the query.explain() method to diagnose which I didn't try previously. What is the level of logging by default?

@djpongh djpongh modified the milestones: 2.0 DB 10, 2.0 DB8 Jun 9, 2017

@djpongh djpongh modified the milestones: 2.0 DB 14, 2.0 DB 10, 2.0.0 Jul 7, 2017

@djpongh djpongh added backlog and removed ready labels Jul 7, 2017

jamiltz added a commit to couchbaselabs/couchbase-mobile-portal that referenced this issue Oct 4, 2017

jamiltz added a commit to couchbaselabs/couchbase-mobile-portal that referenced this issue Oct 4, 2017

jamiltz added a commit to couchbaselabs/couchbase-mobile-portal that referenced this issue Oct 18, 2017

@djpongh djpongh added the P1: high label Nov 17, 2017

@pasin

This comment has been minimized.

Contributor

pasin commented Nov 18, 2017

I understand that this is for travel sample app. @jamiltz / @rajagp is this still an issue?

@jamiltz

This comment has been minimized.

Contributor

jamiltz commented Nov 18, 2017

Haven't seen this issue happen again so I'll close the ticket.

@jamiltz jamiltz closed this Nov 18, 2017

@jamiltz jamiltz removed the backlog label Nov 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment