Can a primary key value be a string containing space character(s)?


Is it allowed to have primary key values which are names (AdonisJs = string & MySQL = varchar) containing spaces?

I am asking because each time I do something like this:

const id = 'Primary Key Value With Space Characters'
const foo = await Foo.find(id)

I do not get what I want.

But when id = 'PrimaryKeyValueWithoutSpaceCharacter' all is right.

I do not get my foo instance.


When using Adonis you really want to be using an auto-incrementing integer as your primary key. I would not deviate from this rule under any circumstances.


Thanks but plenty of situations require to have relational database tables with a specific named ID which is not auto increment and which is not integer. I care a lot about DB design so pardon me to disagree with you.


There are indeed; but Adonis is an active record solution modelled on Laravel/Rails and the primary key is a long-standing convention. I would not use Adonis under your circumstances.


If Virk or Romain Lanz confirms what you say (primary key must be an auto increment integer id) , that will be a big problem to me.

I had to change my primary keys nature because of how DB design works and the documentation says it is allowed. But I am facing troubles whenever my primary key is a string containing white space characters.


If you are not using autoincrement, then you need to tell Lucid about it.

class User extends Model {
  static get incrementing () {
    return false


Yes, I did that before thanks to the clear documentation you wrote, but my issue is about white spaces in primary key’ values @virk Thank you


What’s the issue you are facing?