question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A select with number at start of value throws an error

See original GitHub issue

Bug report

Describe the bug

If you create a list with numbers at the start of the value of will throw an error on start.

message: 'Syntax Error: Expected Name, found Int "0"',

To Reproduce

  1. Create a list like:
keystone.createList('ExampleList', {
  fields: {
    age: {
      type: Select,
      options: '0-18,19-35,36-50,50+',
    },
  },
});
  1. Start Keystone.

It doesn’t seem to matter if you use the array notation either:

keystone.createList('ExampleList', {
  fields: {
    age: {
      type: Select,
      options: [
        { label: '0-18', value: '0-18' },
        { label: '19-35', value: '19-35' },
        { label: '36-50', value: '36-50' },
        { label: '50+', value: '50+' },
      ],
    },
  },
});

Expected behaviour

I can’t see a clear reason why this cannot work. There are no limitations on storing this in a text field in the DB or on the possible values in HTML.

System information

I was using Knex Adapter

Additional context

Is Monday.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
timlesliecommented, Jan 29, 2020

Solution options:

  1. Continue to use enum and generate better error messages and provide more explicit docs.
  2. Change our implementation away from using enum to support a broader range of options. This would require a major breaking change and would require a significant change to how we handle this field type. I’m not sure there are any good reasons to do this, but it’s something we should discuss.

Implementing the docs and error messages in option 1) is something we can and should do before we make a final decision on option 2).

0reactions
MadeByMikecommented, Feb 12, 2020

I really think the solution is to fix this even if it’s a breaking change. It makes no senses to limit the types of data that people can put in the value of a select. I need to understand more about how this is a breaking change.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Oracle - Select statement throwing an error - Stack Overflow
is there any way I can do a cast to that column and get just the numbers in it. I need only numbers...
Read more >
How to correct a #VALUE! error - Microsoft Support
Type a 4 in cell B1. Then in C1 type this formula =B1-A1. If you get the #VALUE! error, go to the next...
Read more >
Db2 11 - SQL error codes - IBM
AN UNSUPPORTED SQLTYPE WAS ENCOUNTERED IN POSITION position-number OF THE SELECT-LIST; Start of change -352 End of change
Read more >
Less than (<) - JavaScript - MDN Web Docs
BigInt and number values can be compared together. ... be converted to a BigInt value (it throws a syntax error when passed to...
Read more >
2 Server Error Message Reference - MySQL :: Developer Zone
Check the %d value to see what the OS error means. For example, 28 indicates that you have run out of disk space....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found