2017-03-16 19:16:56 +00:00
|
|
|
// Copyright 2016 Mozilla
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
|
|
// this file except in compliance with the License. You may obtain a copy of the
|
|
|
|
// License at http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
// Unless required by applicable law or agreed to in writing, software distributed
|
|
|
|
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
|
|
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
|
|
// specific language governing permissions and limitations under the License.
|
|
|
|
|
|
|
|
extern crate mentat_query;
|
|
|
|
|
2017-04-17 20:14:30 +00:00
|
|
|
use mentat_core::ValueType;
|
|
|
|
|
2017-03-16 19:16:56 +00:00
|
|
|
use self::mentat_query::{
|
|
|
|
PlainSymbol,
|
|
|
|
};
|
|
|
|
|
|
|
|
error_chain! {
|
|
|
|
types {
|
|
|
|
Error, ErrorKind, ResultExt, Result;
|
|
|
|
}
|
|
|
|
|
|
|
|
errors {
|
2017-04-17 20:14:30 +00:00
|
|
|
InputTypeDisagreement(var: PlainSymbol, declared: ValueType, provided: ValueType) {
|
|
|
|
description("input type disagreement")
|
|
|
|
display("value of type {} provided for var {}, expected {}", provided, var, declared)
|
|
|
|
}
|
|
|
|
|
2017-03-16 19:16:56 +00:00
|
|
|
UnknownFunction(name: PlainSymbol) {
|
|
|
|
description("no such function")
|
|
|
|
display("no function named {}", name)
|
|
|
|
}
|
|
|
|
|
|
|
|
InvalidNumberOfArguments(name: PlainSymbol, number: usize, expected: usize) {
|
|
|
|
description("invalid number of arguments")
|
|
|
|
display("invalid number of arguments to {}: expected {}, got {}.", name, expected, number)
|
|
|
|
}
|
|
|
|
|
Use Rc for TypedValue, Variable, and query Ident keywords. (#395) r=nalexander
Part 1, core: use Rc for String and Keyword.
Part 2, query: use Rc for Variable.
Part 3, sql: use Rc for args in SQLiteQueryBuilder.
Part 4, query-algebrizer: use Rc.
Part 5, db: use Rc.
Part 6, query-parser: use Rc.
Part 7, query-projector: use Rc.
Part 8, query-translator: use Rc.
Part 9, top level: use Rc.
Part 10: intern Ident and IdentOrKeyword.
2017-03-29 20:18:17 +00:00
|
|
|
UnboundVariable(name: PlainSymbol) {
|
Implement :order. (#415) (#416) r=nalexander
This adds an `:order` keyword to `:find`.
If present, the results of the query will be an ordered set, rather than
an unordered set; rows will appear in an ordered defined by each
`:order` entry.
Each can be one of three things:
- A var, `?x`, meaning "order by ?x ascending".
- A pair, `(asc ?x)`, meaning "order by ?x ascending".
- A pair, `(desc ?x)`, meaning "order by ?x descending".
Values will be ordered in this sequence for asc, and in reverse for desc:
1. Entity IDs, in ascending numerical order.
2. Booleans, false then true.
3. Timestamps, in ascending numerical order.
4. Longs and doubles, intermixed, in ascending numerical order.
5. Strings, in ascending lexicographic order.
6. Keywords, in ascending lexicographic order, considering the entire
ns/name pair as a single string separated by '/'.
Subcommits:
Pre: make bound_value public.
Pre: generalize ErrorKind::UnboundVariable for use in order.
Part 1: parse (direction, var) pairs.
Part 2: parse :order clause into FindQuery.
Part 3: include order variables in algebrized query.
We add order variables to :with, so we can reuse its type tag projection
logic, and so that we can phrase ordering in terms of variables rather
than datoms columns.
Part 4: produce SQL for order clauses.
2017-04-14 23:10:56 +00:00
|
|
|
description("unbound variable in order clause or function call")
|
Use Rc for TypedValue, Variable, and query Ident keywords. (#395) r=nalexander
Part 1, core: use Rc for String and Keyword.
Part 2, query: use Rc for Variable.
Part 3, sql: use Rc for args in SQLiteQueryBuilder.
Part 4, query-algebrizer: use Rc.
Part 5, db: use Rc.
Part 6, query-parser: use Rc.
Part 7, query-projector: use Rc.
Part 8, query-translator: use Rc.
Part 9, top level: use Rc.
Part 10: intern Ident and IdentOrKeyword.
2017-03-29 20:18:17 +00:00
|
|
|
display("unbound variable: {}", name)
|
2017-03-16 19:16:56 +00:00
|
|
|
}
|
2017-03-20 14:11:32 +00:00
|
|
|
|
|
|
|
NonNumericArgument(function: PlainSymbol, position: usize) {
|
|
|
|
description("invalid argument")
|
|
|
|
display("invalid argument to {}: expected numeric in position {}.", function, position)
|
|
|
|
}
|
2017-03-24 20:09:32 +00:00
|
|
|
|
2017-04-19 23:16:19 +00:00
|
|
|
InvalidLimit(val: String, kind: ValueType) {
|
|
|
|
description("invalid limit")
|
|
|
|
display("invalid limit {} of type {}: expected natural number.", val, kind)
|
|
|
|
}
|
|
|
|
|
2017-03-24 20:09:32 +00:00
|
|
|
NonMatchingVariablesInOrClause {
|
|
|
|
// TODO: flesh out.
|
|
|
|
description("non-matching variables in 'or' clause")
|
|
|
|
display("non-matching variables in 'or' clause")
|
|
|
|
}
|
2017-04-28 09:44:11 +00:00
|
|
|
|
|
|
|
NonMatchingVariablesInNotClause {
|
|
|
|
// TODO: flesh out.
|
|
|
|
description("non-matching variables in 'not' clause")
|
|
|
|
display("non-matching variables in 'not' clause")
|
|
|
|
}
|
2017-03-16 19:16:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|