Skip to content

db/insert tries to make a parameter for db/table when params has no table name #89

Open
@LeviSchuck

Description

@LeviSchuck

While following example code in the authentication docs

It appears that it is attempting to run the following sql

insert into account (password, db/table, email) values (?, ?, ?);

With the params being set to.

@{:db/table @{:keys (:email :password) :required true} :email "example@example.com" :password "....."}

I've tracked this down in the code.. it seems that params will accept input without a table

(def params
  (params # nothing here
    (validates [:email :password] :required true)
    (permit [:email :password])))

while later in the request

(params ?)
(hash-password ?)
(db/insert :account ?)

The correct way of doing things seems to be

(def params
  (params :account
    (validates [:email :password] :required true)
    (permit [:email :password])))
(params ?)
(hash-password ?)
(db/insert ?) # No longer include the table name

It was really confusing to get an error like invalid syntax around /, which required hacking in printf's to find the cause.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions