# Operator does not exist: integer = character varying

**URL:** <https://community.forestadmin.com/t/operator-does-not-exist-integer-character-varying/1038>\
**Category:** Help me!\
**Created:** [September 28, 2020, 12:00pm UTC](https://community.forestadmin.com/t/operator-does-not-exist-integer-character-varying/1038 "2020-09-28T12:00:19Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexandre\_TITEUX](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/alexandre_titeux/32/844_2.png) [@Alexandre\_TITEUX](https://community.forestadmin.com/u/Alexandre_TITEUX)\
**Post date:** [September 28, 2020, 12:00pm UTC](https://community.forestadmin.com/t/operator-does-not-exist-integer-character-varying/1038/1 "2020-09-28T12:00:19Z")

</div>

Hey, i want To add relationships to my modèle.  
But i have this error  
` Unexpected error: operator does not existe: integer = caractère varying`

And there is my relationship

```javascript
       Address.hasOne(models.user, {
           foreignKey: "uid",
           targetKey: 'name'
       });

```

I think it’s dont work because my primary key in User is a varchar…  
So i dont know how To tell my primary key is a varchar and not a int.

(Sorry for my bad english…)

- Express Version:4.16.3
- Sequelize Version:5.15.1

---

<div class="post-metadata">

**Author:** ![louis](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/louis/32/4_2.png) [@louis](https://community.forestadmin.com/u/louis)\
**Post date:** [September 28, 2020, 1:02pm UTC](https://community.forestadmin.com/t/operator-does-not-exist-integer-character-varying/1038/2 "2020-09-28T13:02:35Z")

</div>

Hey @Alexandre_TITEUX 👋 and welcome to our community!

Would you mind sharing your User model definition (models/user.js file)?

Thanks

---

<div class="post-metadata">

**Author:** ![Alexandre\_TITEUX](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/alexandre_titeux/32/844_2.png) [@Alexandre\_TITEUX](https://community.forestadmin.com/u/Alexandre_TITEUX)\
**Post date:** [September 28, 2020, 1:50pm UTC](https://community.forestadmin.com/t/operator-does-not-exist-integer-character-varying/1038/3 "2020-09-28T13:50:03Z")

</div>

Here

```javascript
// This model was generated by Lumber. However, you remain in control of your models.
// Learn how here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models
module.exports = (sequelize, DataTypes) => {
    const { Sequelize } = sequelize;
    // This section contains the fields of your model, mapped to your table's columns.
    // Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
    const User = sequelize.define('user', {
        uid: {
            type: DataTypes.STRING,
            primaryKey: true,
            allowNull: false,
        },
        firstname: {
            type: DataTypes.STRING,
            allowNull: false,
        },
        lastname: {
            type: DataTypes.STRING,
            allowNull: false,
        },
    }, {
        tableName: 'user',
        timestamps: false,
        schema: process.env.DATABASE_SCHEMA,
    });

    // This section contains the relationships for this model. See: https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships.
    User.associate = (models) => {
        User.belongsTo(models.address, {
            foreignKey: {
                name: 'addressIdKey',
                field: 'addressId',
            },
            as: 'address',
        });
    };

    return User;
};

```

---

<div class="post-metadata">

**Author:** ![louis](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/louis/32/4_2.png) [@louis](https://community.forestadmin.com/u/louis)\
**Post date:** [September 29, 2020, 8:14am UTC](https://community.forestadmin.com/t/operator-does-not-exist-integer-character-varying/1038/4 "2020-09-29T08:14:06Z")

</div>

@Alexandre_TITEUX, can you try to define your field as follow?

```javascript
uid: {
  type: DataTypes.INTEGER,
  primaryKey: true,
  allowNull: false,
},

```

---

<div class="post-metadata">

**Author:** ![Alexandre\_TITEUX](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/alexandre_titeux/32/844_2.png) [@Alexandre\_TITEUX](https://community.forestadmin.com/u/Alexandre_TITEUX)\
**Post date:** [September 30, 2020, 8:12am UTC](https://community.forestadmin.com/t/operator-does-not-exist-integer-character-varying/1038/5 "2020-09-30T08:12:21Z")

</div>

It’s doesn’t work.  
But I want to do a HasOne in my address entity

```javascript
        Address.hasOne(models.user, {
          foreignKey: {
            name: 'addressIdKey',
            field: 'addressId',
          },
          as: 'user',
        });

```

But when I do this config it’s written :

```javascript
Unexpected error: column user.id does not exist

```

And then when I do this I have this error:

```javascript
Unexpected error: operator does not exist: integer = character varying

```

My user.uid is a string.  
user.addressId: Number  
address.id: Number

And all my hasOne don’t work.

---

<div class="post-metadata">

**Author:** ![anon36130554](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@anon36130554](https://community.forestadmin.com/u/anon36130554)\
**Post date:** [September 30, 2020, 9:59am UTC](https://community.forestadmin.com/t/operator-does-not-exist-integer-character-varying/1038/6 "2020-09-30T09:59:08Z")

</div>

Hello @Alexandre_TITEUX, welcome to our community 🎊🎉

I have been able to reproduce your issue, looks like hasOne relationships with custom primary key (other than `id`) doesn’t work.

I’m digging a little bit more and I will keep you in touch.

Steve.

---

<div class="post-metadata">

**Author:** ![Alexandre\_TITEUX](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/alexandre_titeux/32/844_2.png) [@Alexandre\_TITEUX](https://community.forestadmin.com/u/Alexandre_TITEUX)\
**Post date:** [September 30, 2020, 10:06am UTC](https://community.forestadmin.com/t/operator-does-not-exist-integer-character-varying/1038/7 "2020-09-30T10:06:39Z")

</div>

Ok, thanks for you’re help !

---

<div class="post-metadata">

**Author:** ![anon36130554](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@anon36130554](https://community.forestadmin.com/u/anon36130554)\
**Post date:** [September 30, 2020, 3:08pm UTC](https://community.forestadmin.com/t/operator-does-not-exist-integer-character-varying/1038/8 "2020-09-30T15:08:25Z")

</div>

Hello @Alexandre_TITEUX 👋

We have identified the issue, and we are working for a fix. I can’t give you any ETA but you can downgrade `forest-express-sequelize` to version 6.3.6 and it should work (keep me in touch if you encounter issues after having changed the version).

We will ping you as soon as the bug is fixed.

Sorry for the inconvenience, I hope this will help.

Steve.

---

<div class="post-metadata">

**Author:** ![Alexandre\_TITEUX](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/alexandre_titeux/32/844_2.png) [@Alexandre\_TITEUX](https://community.forestadmin.com/u/Alexandre_TITEUX)\
**Post date:** [October 1, 2020, 7:39am UTC](https://community.forestadmin.com/t/operator-does-not-exist-integer-character-varying/1038/9 "2020-10-01T07:39:28Z")

</div>

Hello @anon36130554  
Thanks for your help but when I downgrade forest-express-sequelize it still doesn’t work, I have the same Issue

---

<div class="post-metadata">

**Author:** ![anon39848301](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@anon39848301](https://community.forestadmin.com/u/anon39848301)\
**Post date:** [October 1, 2020, 8:13am UTC](https://community.forestadmin.com/t/operator-does-not-exist-integer-character-varying/1038/10 "2020-10-01T08:13:47Z")

</div>

Hi @Alexandre_TITEUX,

Sadly, I’m not able to reproduce your issue using 6.3.6.

I’ll need some more infos on your setup:

- Could you provide me your project name so I can dig into this ?
- Which version of `forest-express-sequelize` were you using before the downgrade ?
- `npm ls forest-express-sequelize` does return you 6.3.6 ?

---

<div class="post-metadata">

**Author:** ![Alexandre\_TITEUX](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/alexandre_titeux/32/844_2.png) [@Alexandre\_TITEUX](https://community.forestadmin.com/u/Alexandre_TITEUX)\
**Post date:** [October 1, 2020, 11:24am UTC](https://community.forestadmin.com/t/operator-does-not-exist-integer-character-varying/1038/11 "2020-10-01T11:24:51Z")

</div>

You’re right @anon39848301 ,  
I’m so sorry I didn’t downgrade well forest-express-sequelize and now it’s working better.  
Thank you.  
And when it’s will be fixed?

---

<div class="post-metadata">

**Author:** ![anon39848301](https://avatars.discourse-cdn.com/v4/letter/a/b9e5f3/32.png) [@anon39848301](https://community.forestadmin.com/u/anon39848301)\
**Post date:** [October 1, 2020, 11:57am UTC](https://community.forestadmin.com/t/operator-does-not-exist-integer-character-varying/1038/12 "2020-10-01T11:57:18Z")

</div>

No problem.

The ticket is created, but I can’t really give you any ETA. I’ll link this thread to the ticket, so you’ll be informed once released.

---

<div class="post-metadata">

**Author:** ![GuillaumeGautreau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/guillaumegautreau/32/557_2.png) [@GuillaumeGautreau](https://community.forestadmin.com/u/GuillaumeGautreau)\
**Post date:** [October 5, 2020, 6:40am UTC](https://community.forestadmin.com/t/operator-does-not-exist-integer-character-varying/1038/13 "2020-10-05T06:40:00Z")

</div>

Hello @Alexandre_TITEUX,

We just released `forest-express-sequelize` version `6.3.13` that will fix your issue. Can you test it on your side and validate that it works as expected?

Thanks

---

<div class="post-metadata">

**Author:** ![Alexandre\_TITEUX](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/alexandre_titeux/32/844_2.png) [@Alexandre\_TITEUX](https://community.forestadmin.com/u/Alexandre_TITEUX)\
**Post date:** [October 6, 2020, 7:35am UTC](https://community.forestadmin.com/t/operator-does-not-exist-integer-character-varying/1038/14 "2020-10-06T07:35:39Z")

</div>

Thanks, it’s working now !
