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.

Custom id field does not work in get request with id

See original GitHub issue

Steps to reproduce

  • Change id field as per bellow code in users.model.js
const DataTypes = Sequelize.DataTypes;

module.exports = function(app) {
  const sequelizeClient = app.get("sequelizeClient");
  const users = sequelizeClient.define(
    "user_system",
    {
      uid: {
        type: DataTypes.INTEGER(10).UNSIGNED,
        allowNull: false,
        primaryKey: true,
        autoIncrement: true
      },
      userid: {
        type: DataTypes.STRING(20),
        allowNull: false,
        defaultValue: "",
        unique: true
      },
     // ...
  • Using postman, call this url using get with proper authentication http://localhost:3030/users/8

Expected behavior

Should return the user data but it give me error

Actual behavior

The GET request give me bellow error

    "name": "NotFound",
    "message": "No record found for id '8'",
    "code": 404,
    "className": "not-found",
    "data": {
        "name": "SequelizeDatabaseError",
        "parent": {
            "code": "ER_BAD_FIELD_ERROR",
            "errno": 1054,
            "sqlState": "42S22",
            "sqlMessage": "Unknown column 'user_system.id' in 'where clause'",
            "sql": "SELECT `uid`, `userid`, `password`, `name`, `icno`, `position`, `email`, `mobile`, `phone`, `fax`, `address`, `employee_id`, `dtcreate`, `dtlastin`, `dtmodified`, `remarks`, `img_filename`, `race`, `sex`, `utype_id`, `ulevel_id`, `ucommunity_id`, `areajkp_id`, `communities`, `areas`, `active` FROM `user_system` AS `user_system` WHERE `user_system`.`id` = '8';"
        },
        "original": {
            "code": "ER_BAD_FIELD_ERROR",
            "errno": 1054,
            "sqlState": "42S22",
            "sqlMessage": "Unknown column 'user_system.id' in 'where clause'",
            "sql": "SELECT `uid`, `userid`, `password`, `name`, `icno`, `position`, `email`, `mobile`, `phone`, `fax`, `address`, `employee_id`, `dtcreate`, `dtlastin`, `dtmodified`, `remarks`, `img_filename`, `race`, `sex`, `utype_id`, `ulevel_id`, `ucommunity_id`, `areajkp_id`, `communities`, `areas`, `active` FROM `user_system` AS `user_system` WHERE `user_system`.`id` = '8';"
        },
        "sql": "SELECT `uid`, `userid`, `password`, `name`, `icno`, `position`, `email`, `mobile`, `phone`, `fax`, `address`, `employee_id`, `dtcreate`, `dtlastin`, `dtmodified`, `remarks`, `img_filename`, `race`, `sex`, `utype_id`, `ulevel_id`, `ucommunity_id`, `areajkp_id`, `communities`, `areas`, `active` FROM `user_system` AS `user_system` WHERE `user_system`.`id` = '8';"
    },
    "errors": {}
}```

### System configuration

Tell us about the applicable parts of your setup.

**Module versions** (especially the part that's not working):
Feathers-sequelize   "version": "3.1.0"

**NodeJS version**:
v8.9.4

**Operating System**:
Windows10 Home

**Browser Version**:
Chrome Version 64.0.3282.140 (Official Build) (32-bit)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
dafflcommented, May 24, 2018

You also have to add the id service option in your users.service.js.

0reactions
HarisHashimcommented, May 26, 2018

Thanks and you are right about that too. Today I get the same problem for other services as well!

Thanks again and closing this question.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom field with id <id> doesn't exist
Hi, For context, I'm trying to implement a searchable custom field in Jira. My understanding is that I need to update the custom...
Read more >
Custom id field in Django model - python - Stack Overflow
I want to use custom id field in my model and i know about uuid module. The problem is i don't know where...
Read more >
Custom field with ID 0 is not on given object - Developers & API
Trying to create a simple task with custom fields, but getting the error message above. The ID im specifiying is from the get...
Read more >
Query for Id of a Custom Field - Salesforce Developers
I'm not wanting the ID for a record in the object I want the Id for the actual field.
Read more >
Why i can't get custom fields value or post ID via Ajax?
Because they're 2 different requests, and the post doesn't carry over to the AJAX request from the initial load. Nothing is remembered ...
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