MPD icon indicating copy to clipboard operation
MPD copied to clipboard

Stickers and integer values

Open jcorporation opened this issue 7 months ago • 1 comments

I use stickers to save song playback statistics and ratings. All this values are integers, e.g. the playCount. MPD can save values in the sticker database only as string. Converting the integers to strings and saving them is not the problem.

The problem exists in the query interface:

  • The = operator works as expected for integers.
  • But for the supported > and < this does not work as an user will expect this.

Example:

  • I have the 468 48 53 as values for a sticker named playCount.
  • SQL select: select value from sticker where name="playCount" and value > 5;
  • This returns only 53 as the operator does not work in a numeric context

Possible solutions for this:

  • Leave the schema untouched
  • Add new api to emit sql selects with casts: select value from sticker where name="elapsed" and cast(value as int) > 5
  • Add a int column to the schema
  • Add new api to set and retrieve the int values

I am happy to contribute code to solve the problem.

@MaxKellermann: Which solution would you prefer?

jcorporation avatar Nov 06 '23 18:11 jcorporation

#1895 implements the cast solution.

jcorporation avatar Nov 07 '23 21:11 jcorporation