balderdashy / sails

Realtime MVC Framework for Node.js
https://sailsjs.com
MIT License
22.86k stars 1.95k forks source link

Document that `type:'string'` attributes are automigrated as VARCHAR by default and not TEXT (and thus silent truncation if you use long strings and don't specify a columnType) #4401

Open rahulserver opened 6 years ago

rahulserver commented 6 years ago

Sails version: 1.0.1 Node version: 8.11.1 NPM version: 4.0.5 DB adapter name: sails-mysql DB adapter version: 1.0.0 Operating system: windows/ubuntu


I just realized that fields with type 'string' get persisted to database(MySql) silently without any error or warning if their length is over 255 chars.

Its a SERIOUS BUG IMO and must be either resolved quickly or should be explicitly mentioned in documentation of sailsjs or sails-mysql adapter.

I temporarily found a fix about it which is by using the columnType attribute. Eg:

description: {
      type: 'string',
      required: true,
      columnType: 'text'
    }
sailsbot commented 6 years ago

@rahulserver Thanks for posting, we'll take a look as soon as possible.


For help with questions about Sails, click here. If you’re interested in hiring @sailsbot and her minions in Austin, click here.

mikermcneil commented 6 years ago

@rahulserver thanks for mentioning this! I agree-- it'd be great to see this more clearly called out in the docs

raqem commented 5 years ago

@rahulserver thanks again for bring this up. There has been a little more info added to the documentation here This issue also seems related and you may find helpful info/tips from this discussion.
https://github.com/balderdashy/sails/issues/4627