Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

fix decimal scale and precision parsing #67

Merged
merged 2 commits into from
Jun 8, 2018

Conversation

TokiTori
Copy link
Contributor

@TokiTori TokiTori commented Jun 7, 2018

I created table price_list with field price DECIMAL(34, 10). And when I try to select data from this table, I get error. Then I create same table and field without space between precision and scale - query working.

** (exit) exited in: GenServer.call(Sqlitex.Server, {:query, "select * from price_list ORDER BY company_id limit 1", []}, 5000)
    ** (EXIT) an exception was raised:
        ** (ArgumentError) argument error
            :erlang.binary_to_integer(" 10")
            (elixir) lib/enum.ex:1294: Enum."-map/2-lists^map/1-0-"/2
            (elixir) lib/enum.ex:1294: Enum."-map/2-lists^map/1-0-"/2
            (sqlitex) lib/sqlitex/row.ex:58: Sqlitex.Row.translate_value/1
            (elixir) lib/enum.ex:1294: Enum."-map/2-lists^map/1-0-"/2
            (elixir) lib/enum.ex:1294: Enum."-map/2-lists^map/1-0-"/2
            (sqlitex) lib/sqlitex/row.ex:16: Sqlitex.Row.build_row/4
            (sqlitex) lib/sqlitex/row.ex:5: anonymous fn/5 in Sqlitex.Row.from/4
    (elixir) lib/gen_server.ex:836: GenServer.call/3

@sourcelevel-bot
Copy link

Hello, @TokiTori! This is your first Pull Request that will be reviewed by Ebert, an automatic Code Review service. It will leave comments on this diff with potential issues and style violations found in the code as you push new commits. You can also see all the issues found on this Pull Request on its review page. Please check our documentation for more information.

@mmmries
Copy link
Collaborator

mmmries commented Jun 8, 2018

@TokiTori thanks for contributing this fix! Can you add a unit test to cover this case? You could add it right after the existing test for creating decimal columns with precision.

@mmmries
Copy link
Collaborator

mmmries commented Jun 8, 2018

I just want to make sure we keep this case covered if we refactor later to do more complete parsing.

@mmmries
Copy link
Collaborator

mmmries commented Jun 8, 2018

💛 💜 ❤️ 💙 💚 💛 💜 ❤️ 💙 💚 💛 💜 ❤️ 💙 💚 This looks great thanks!

@mmmries mmmries merged commit f4c2b36 into elixir-sqlite:master Jun 8, 2018
@mmmries
Copy link
Collaborator

mmmries commented Jun 8, 2018

released this fix in 1.4.2 on hex

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants