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

SQLite text search doesn't work #1112

Closed
Boscop opened this Issue Aug 17, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@Boscop

Boscop commented Aug 17, 2017

I'm trying to do text search in SQLite, but when I create a virtual FTS table, like this:
create virtual table foo using fts5 (content='files', path);

I get this error:

error: proc-macro derive panicked
 --> src\models\schema.rs:1:1
  |
1 | infer_schema!("dotenv:DATABASE_URL");
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: message: Could not infer table foo: StringError("Diesel only supports
tables with primary keys. Table foo has no primary key")
  = note: this error originates in a macro outside of the current crate

How can I get this to work? Do I have to create a FTS table with a primary key? If so, how?
Can I then declare the table using the table! macro?
Does diesel support the MATCH expression or do I have to use a custom query using the sql! macro?

@killercup

This comment has been minimized.

Member

killercup commented Aug 17, 2017

First, I don't think we should try to infer virtual tables by default (just like we don't infer views). Does it work if you use table! (with an id column of your choosing)?

Second, we have no support for MATCH, but you should be able to get it to work with diesel_infix_operator!.

@Boscop

This comment has been minimized.

Boscop commented Aug 17, 2017

It works when I don't use the infer_schema! macro (because it doesn't support excluding tables), but instead write the schemas of all tables manually and then:

table! {
	foo(rowid) {
		rowid -> Integer,
		path -> Text,
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment