Commit graph

65 commits

Author SHA1 Message Date
Tom Jaspers
2ce38a254e Sort is case insensitive by default
Renamed "ignore_case" to more canonical "case_insensitive"
2015-04-18 10:25:28 +02:00
Tom Jaspers
18d262a59c Sort can ignore case if configured to do so
- Config option `sort_ignore_case`
- Default behavior was (and is) case sensitive
2015-04-17 14:24:56 +02:00
Bruno Cauet
bad87c1668 Delete hacks & workarounds for python 2.6 2015-04-01 10:46:22 +02:00
Bruno Cauet
86559bcb1a Implement repr() on Query & its subclasses.
This should help with #1359-style issues.
2015-03-25 10:56:17 +01:00
Bruno Cauet
a96f2fd3c9 Fix pep8 2015-03-19 13:51:20 +01:00
Bruno Cauet
bcd57bd2b5 Test queries building sort management in smartplaylist
Slighly modify Sort parsing: avoid building MultiplSort() instances
comptised of a single sort, but return that sort instead, since it wraps
things with any gain.
2015-03-18 18:53:41 +01:00
Bruno Cauet
45c0c9b3cb Deal with sorting
Try to follow any sort found & manage absence of sort. When there are
multiple sort directives given, concatenate them.

Tests not extended yet.
2015-03-18 18:09:42 +01:00
Bruno Cauet
e00282b4fe Implement hash() for query subclasses
It is implemented on mutable queries as well, which is bad. IMPORTANT:
don't mutate your queries if you want to put them in a set or in a dict
(as keys).
2015-03-16 17:28:00 +01:00
Bruno Cauet
64614ff579 Query.__eq__: fix indents 2015-03-16 17:28:00 +01:00
Bruno Cauet
4151e81969 Implement __eq__ for all Query subclasses
Tests are a bit light.
2015-03-16 17:01:14 +01:00
Bruno Cauet
a1b048f5de RegexpQuery: fix typo: false → fast 2015-03-16 17:01:11 +01:00
Bruno Cauet
7476d6be46 InvalidQuery*Error extend ParsingError
And InvalidQueryArgumentTypeError does not extend TypeError anymore.
2015-02-09 19:25:23 +01:00
Bruno Cauet
f443e0bfc5 InvalidQueryArgumentTypeError does not extend InvalidQueryError
Places where InvalidQueryArgumentTypeError may be raised (i.e. all
current ones) may not know the query therefore it cannot be an
InvalidQueryError. The InvalidQueryArgumentTypeError is caught in
beets.library.Library._fetch() and an InvalidQueryError is then raised.

Improve #1290.
2015-02-09 15:44:49 +01:00
Bruno Cauet
54887e7655 Widen usage of InvalidQueryError
Replace previous InvalidQueryError with InvalidQueryArgumentTypeError
which extends the former as TypeError. However they lack context: the
query that caused the error.

Raise an InvalidQueryError when a shell-like expression cannot be parsed
by shlex.

Improve #1290.
2015-02-09 15:28:06 +01:00
Bruno Cauet
557330e994 Fix open numeric ranges
Also improve InvalidQueryError message and update
NumericQuery._convert() docstring.

Fix #1288.
2015-01-31 14:21:32 +01:00
Bruno Cauet
02d8e88ef1 Replace all mentions of 'str' with 'bytes' 2015-01-20 12:48:15 +01:00
Bruno Cauet
6fff7a954c Import unicode_literals in beets.dbcore 2015-01-19 17:18:50 +01:00
Bruno Cauet
90b388b775 Use __future__ imports but unicode_literals everywhere
Include import of __future__ features division, absolute_imports and
print_function everywhere. Don't add unicode_literals yet for it is
harder to convert.

Goal is smoothing the transition to python 3.
2015-01-19 12:25:16 +01:00
Bruno Cauet
08c9ad43fa Document the new behaviour in docstrings & changelog 2015-01-15 11:55:42 +01:00
Bruno Cauet
f4b4847919 Rename exception: InvalidQuery → InvalidQueryError
Follow PEP8.
2015-01-15 11:47:35 +01:00
Bruno Cauet
3804eb5b52 Stop on invalid queries instead of ignoring them
So far an invalid query won't be applied:
    $ beet ls The Beatles year:196a
will be treaded as
    $ beet ls The Beatles
With this commit it stops beets, returns 1 and produces
    $ invalid query: u'196a' is not an int or a float
This applies to any querying and therefore on many command, plugins and
some configuration options.
Invalid queries exist on numeric fields and on regular expression usage.

Compile regular expression queries upon instantiation instead of upon
each match test.

The reporting can be improved (give more context). Fix #1219.
2015-01-14 11:28:50 +01:00
Frederik “Freso” S. Olesen
4b1f0cbf48 Happy 2015. ;)
See 7a410f636b

Command used:

    git grep -l 'Copyright 201'|xargs sed -i -E 's/Copyright 201./Copyright 2015/'`
2015-01-08 21:37:09 +01:00
Adrian Sampson
2b1353a4f1 Malformed date queries no longer crash 2014-10-04 16:50:50 -07:00
Thomas Scholtes
ad71af2c3d Add NoneQuery
This makes fast SQL queries for singletons possible
2014-09-17 11:23:00 +02:00
Adrian Sampson
f9c6dd6d67 Move SmartArtistSort to library (#953)
Models can now have a dict of special sort classes.
2014-09-15 19:43:22 -07:00
Adrian Sampson
e2b3fafefa Remove SortedQuery (#953)
This turned out to be less useful than I was hoping.
2014-09-15 18:39:49 -07:00
Adrian Sampson
eb89d3a850 The demise of get_query_sort (#953)
The type tests now live where they ought to live.
2014-09-15 18:37:09 -07:00
Adrian Sampson
044dbfcd38 NumericQuery: Check that the field exists 2014-09-14 12:34:46 +02:00
Adrian Sampson
c57439770b Collapse build_sql into _fetch (#953)
This was getting so short that it made sense to go back from whence it came.
2014-09-13 21:35:19 -07:00
Adrian Sampson
85de214399 Remove SQL ORDER BY sorting option
I don't think anything uses this anymore.
2014-09-13 21:19:32 -07:00
Adrian Sampson
2b921b19fd NullSort instead of None
A more descriptive placeholder for "don't sort".
2014-09-13 20:38:31 -07:00
Adrian Sampson
369533d46f Remove special_sorts
These are not extensible anyway; we'll need another mechanism for that.
2014-09-13 19:47:20 -07:00
Adrian Sampson
4870d7e0fa Roll back fast flexible field sorts (#953)
Sad to see them go, but happy be rid of the SQL injection.
2014-09-13 17:16:12 -07:00
Adrian Sampson
db4e74fd57 Fix mistaken removals 2014-09-12 21:11:53 -07:00
Adrian Sampson
03d0f9dfb3 Fix namedtuple call 2014-09-12 20:59:19 -07:00
Adrian Sampson
bb4082fbfc Style cleanup in sorting 2014-09-12 20:58:25 -07:00
PierreRust
3130a6add9 Minor changes from review (mostly style) 2014-07-24 12:51:21 +02:00
Pierre Rust
d168c6222b Fix formatting (again ...) 2014-07-02 19:26:27 +02:00
Pierre Rust
451f17c99a Fix formatting issue 2014-07-02 19:06:27 +02:00
Pierre Rust
cd1dcf6969 Fix minor formatting and comments issues. 2014-07-02 13:05:33 +02:00
Pierre Rust
18539b0bd1 Fix flake8 warnings. 2014-06-15 22:32:26 +02:00
Pierre Rust
1a995ed8d4 Fix sorting without using the MultipleSort object.
SQL syntax error when using a simple FlexFieldSort.
2014-06-15 22:32:26 +02:00
Pierre Rust
1d61088cfc Sort on computed field implementation.
Sort is implemented in python.
When combining sorts on fixed, flex and computed field, make as
much as possible in sql and finishes the job in python.
2014-06-15 22:32:25 +02:00
Pierre Rust
86c34f8740 Moves default sort specification from code to conf
Default sort order can be set in configuration file with the
`sort_album` and `sort_item` keys.
2014-06-15 22:32:25 +02:00
Pierre Rust
4958ce83c3 Add defaut sort on artist_sort field.
For items and albums, defaulting on artist field if artist field
is empty.
2014-06-15 22:32:25 +02:00
Pierre Rust
3d7814c32e Use implicit continuation for sql generation.
Avoid newlines in the query string.
2014-06-15 22:32:25 +02:00
Pierre Rust
1303a915c1 Sort implementation
* sort can be sepcified using the 'field_name'(+|-) syntax
 * supports fixed fields and flexible attributes
 * includes plugins fix for API changes (might have missed some)
2014-06-15 22:32:25 +02:00
Thomas Scholtes
bc55747abc More flake fixes 2014-04-09 19:16:38 +02:00
Adrian Sampson
ab8d008049 use OrQuery for smartplaylist (#575) 2014-03-07 14:38:40 -08:00
Adrian Sampson
a06500fb42 style tweaks in date queries (#551; fixes #542)
The microseconds were being ignored anyway due to the int conversion, so we
might as well not use them here.
2014-02-21 20:17:57 -05:00