# Value "1739608289390985071" is out of range for type integer \[BigInt\]

**URL:** <https://community.forestadmin.com/t/value-1739608289390985071-is-out-of-range-for-type-integer-bigint/2215>\
**Category:** Help me!\
**Created:** [April 1, 2021, 9:39am UTC](https://community.forestadmin.com/t/value-1739608289390985071-is-out-of-range-for-type-integer-bigint/2215 "2021-04-01T09:39:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![JonasKman](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jonaskman/32/1656_2.png) [@JonasKman](https://community.forestadmin.com/u/JonasKman)\
**Post date:** [April 1, 2021, 9:39am UTC](https://community.forestadmin.com/t/value-1739608289390985071-is-out-of-range-for-type-integer-bigint/2215/1 "2021-04-01T09:39:51Z")

</div>

## Expected behavior

Search for “1739608289390985071” should give result for field `objectId` `organization/1739608289390985071`

## Failure Logs

```javascript
error: value "1739608289390985071" is out of range for type integer
    at Parser.parseErrorMessage (/var/www/forest-admin-production/node_modules/pg-protocol/dist/parser.js:278:15)
    at Parser.handlePacket (/var/www/forest-admin-production/node_modules/pg-protocol/dist/parser.js:126:29)
    at Parser.parse (/var/www/forest-admin-production/node_modules/pg-protocol/dist/parser.js:39:38)
    at Socket.<anonymous> (/var/www/forest-admin-production/node_modules/pg-protocol/dist/index.js:10:42)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at Socket.Readable.push (_stream_readable.js:213:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)

```

## Context

Please provide any relevant information about your setup.

- Package Version: forest-express-sequelize 7.0.3
- Express Version: 4.17.1
- Sequelize Version: ~5.15.1
- Database Dialect: pg
- Database Version: 9.4
- Project Name: I don’t want this to be public

---

<div class="post-metadata">

**Author:** ![anon79585656](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@anon79585656](https://community.forestadmin.com/u/anon79585656)\
**Post date:** [April 1, 2021, 1:39pm UTC](https://community.forestadmin.com/t/value-1739608289390985071-is-out-of-range-for-type-integer-bigint/2215/2 "2021-04-01T13:39:37Z")

</div>

Hello @JonasKman,

Thank you for your feedback and welcome to the ForestAdmin community.

Could you please tell me what is the action your are performing when getting this error message? Is it an error server side (where your Forest agent runs) or in your browser?

It would help if I could identify your project. If not sharing the name could you please share with me the values for theses headers, found in the request made from your admin panel to our servers:

```javascript
Forest-Environment-Id: ...
Forest-Project-Id: ...
Forest-Rendering-Id: ...
Forest-Team-Id: ...

```

Could you also share the table definition in your Postgres schema and the model file generated by Lumber for your project?

Thank you

---

<div class="post-metadata">

**Author:** ![JonasKman](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jonaskman/32/1656_2.png) [@JonasKman](https://community.forestadmin.com/u/JonasKman)\
**Post date:** [April 1, 2021, 5:15pm UTC](https://community.forestadmin.com/t/value-1739608289390985071-is-out-of-range-for-type-integer-bigint/2215/3 "2021-04-01T17:15:04Z")

</div>

Hello @anon79585656 ,  
We have Java Longs as ids. (which is sometimes to big for JS).  
When doing a search in the main search field of this collection the error occurs on our forest agent (server side)

## Database Table

```sql
create table subscription
(
    id bigint not null
        constraint subscription_pkey
            primary key,
    version bigint not null,
    date_created timestamp not null,
    end_date timestamp not null,
    last_updated timestamp not null,
    note varchar(255),
    object_id varchar(255) not null,
    product_id bigint not null
        constraint fk1456591d9c2000c2
            references product,
    quantity integer,
    renewal_type varchar(255) not null,
    share_it_purchase_item_id bigint
        constraint fk1456591d2390c009
            references purchase_item,
    start_date timestamp not null
);

```

## Model

```javascript
const { decryptWithFixedSalt, encryptWithFixedSalt } = require('../services/encrypted-fields');
// 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 Subscription = sequelize.define(
    'subscription',
    {
      version: {
        type: DataTypes.BIGINT,
        allowNull: false,
      },
      dateCreated: {
        type: DataTypes.DATE,
        allowNull: false,
      },
      endDate: {
        type: DataTypes.DATE,
        allowNull: false,
      },
      lastUpdated: {
        type: DataTypes.DATE,
        allowNull: false,
      },
      note: {
        type: DataTypes.STRING,
        get() {
          return decryptWithFixedSalt(this.getDataValue('note'));
        },
        set(value) {
          return this.setDataValue('note', encryptWithFixedSalt(value));
        },
      },
      objectId: {
        type: DataTypes.STRING,
        allowNull: false,
      },
      quantity: {
        type: DataTypes.INTEGER,
      },
      renewalType: {
        type: DataTypes.STRING,
        allowNull: false,
      },
      startDate: {
        type: DataTypes.DATE,
        allowNull: false,
      },
    },
    {
      tableName: 'subscription',
      underscored: true,
      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.
  Subscription.associate = (models) => {
    Subscription.belongsTo(models.purchaseItem, {
      foreignKey: {
        name: 'shareItPurchaseItemIdKey',
        field: 'share_it_purchase_item_id',
      },
      as: 'shareItPurchaseItem',
    });
    Subscription.belongsTo(models.product, {
      foreignKey: {
        name: 'productIdKey',
        field: 'product_id',
      },
      as: 'product',
    });
    Subscription.hasMany(models.license, {
      foreignKey: {
        name: 'subscriptionIdKey',
        field: 'subscription_id',
      },
      as: 'licenses',
    });
    Subscription.hasMany(models.productKey, {
      foreignKey: {
        name: 'subscriptionIdKey',
        field: 'subscription_id',
      },
      as: 'productKeys',
    });
  };

  return Subscription;
};

```

Note: The encrypted getter/setter is the only change I did.

```javascript
Forest-Environment-Id: 68385
Forest-Project-Id: 54928
Forest-Rendering-Id: 82745
Forest-Team-Id: 54359

```

---

<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:** [April 2, 2021, 9:42am UTC](https://community.forestadmin.com/t/value-1739608289390985071-is-out-of-range-for-type-integer-bigint/2215/4 "2021-04-02T09:42:09Z")

</div>

Hi @JonasKman,

I’m totally able to reproduce, thanks to your database dump. I’m still investigating to see if there is a quick fix for this - and I will post here if I find something, and I’ll open a ticket on our end.  
Could you confirm that the issue appear only on search, not when using filter ?

Thanks for reporting this 🙌

---

<div class="post-metadata">

**Author:** ![JonasKman](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jonaskman/32/1656_2.png) [@JonasKman](https://community.forestadmin.com/u/JonasKman)\
**Post date:** [April 12, 2021, 8:19am UTC](https://community.forestadmin.com/t/value-1739608289390985071-is-out-of-range-for-type-integer-bigint/2215/5 "2021-04-12T08:19:48Z")

</div>

Yes I can confirm it is working when using as a filter value. Independent of the filtered field being `bigint` or `varchar(255)`.

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [April 19, 2021, 9:04am UTC](https://community.forestadmin.com/t/value-1739608289390985071-is-out-of-range-for-type-integer-bigint/2215/6 "2021-04-19T09:04:41Z")

</div>

Hey @JonasKman ,

We are currently working on a fix. You can’t track the status here: https://share.clickup.com/t/h/gk7007/3VPVG5UDJ5J2YC2

---

<div class="post-metadata">

**Author:** ![anon34731316](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@anon34731316](https://community.forestadmin.com/u/anon34731316)\
**Post date:** [April 22, 2021, 4:51pm UTC](https://community.forestadmin.com/t/value-1739608289390985071-is-out-of-range-for-type-integer-bigint/2215/7 "2021-04-22T16:51:26Z")

</div>

Hi @JonasKman,

The error you faced should be fixed in the version 7.6.3 of `forest-express-sequelize`.  
Could you update it and tell me if it is working properly now?

Thanks! 🙌

---

<div class="post-metadata">

**Author:** ![JonasKman](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/jonaskman/32/1656_2.png) [@JonasKman](https://community.forestadmin.com/u/JonasKman)\
**Post date:** [April 22, 2021, 7:23pm UTC](https://community.forestadmin.com/t/value-1739608289390985071-is-out-of-range-for-type-integer-bigint/2215/8 "2021-04-22T19:23:07Z")

</div>

It works as expected now, thanks for the quick fix 😃
