Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defaults Varchar(255) and UTF8mb4 #4627

Open
Betanu701 opened this issue Jun 19, 2018 · 5 comments
Open

Defaults Varchar(255) and UTF8mb4 #4627

Betanu701 opened this issue Jun 19, 2018 · 5 comments
Labels
does this answer your question? orm Related to models, datastores, orm config, Waterline, sails-hook-orm, etc. question

Comments

@Betanu701
Copy link

Waterline version:0.13
Node version:8.#
NPM version:5.*
Operating system:linux


Note: this really should be for sails-mysql

So there is an issue with MariaDB/Mysql especially on linux machines fresh install of MariaDB. The issue comes from charset UTF8mb4 -> This is the default for MariaDB with a fresh install. The issue comes down to default varchar being set to VARCHAR(255). With UTF8mb4, one can not use VARCHAR(255).
The issue by default strings are defaulting to varchar then to VARCHAR(255). I am not sure if there is a way that we can detect what the charset is currently.

I still like defaulting to 255 because I use UTF8. However this becomes a huge pain for those who do not know that there is a difference and are not wanting to go into setting up their machines to a different character set.

I really do not know the best way to go forward with this issue. My thought would be to have it in the configs so that we can override the default. Not sure though.

@sailsbot
Copy link

@Betanu701 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.

@vpiskunov
Copy link

vpiskunov commented Jun 29, 2018

The alternatives are:
For indexes: use VARCHAR(191) whenever the schema is on UTF8mb4 - check this during initialising of datastore/sails-lift auto-migration time.

For non indexes no changes should be required.

There’s also other workarounds but they would be unnecessary for most users(but could include as an option?):

use a "prefix" index: INDEX(foo(191)), while leaving it VARCHAR(255). Usually "prefix" indexes are useless, but you might have a use case for which it works.

(Plan C here)

@oaksofmamre
Copy link
Member

@Betanu701, for performance reasons, we leave the sizing of fields up to the adaptor (sails-mssql in your case) as each adaptor passes data straight through to the database. I think you’re on the right track though, being aware of what your charset is. as @vpiskunov hints, when you know what your charset is, you can handle it in code first before sending it to your database

@oaksofmamre
Copy link
Member

@Betanu701 @vpiskunov I just came across this - hopefully this can be helpful for you as well: https://sailsjs.com/documentation/concepts/models-and-orm/attributes#?unique

@johnabrams7 johnabrams7 transferred this issue from balderdashy/waterline Mar 6, 2019
@johnabrams7 johnabrams7 added needs documentation question orm Related to models, datastores, orm config, Waterline, sails-hook-orm, etc. labels Mar 6, 2019
@johnabrams7
Copy link
Contributor

johnabrams7 commented Mar 6, 2019

@oaksofmamre @vpiskunov @Betanu701 - Hey everyone, we're moving the Waterline issues to Sails (balderdashy/sails) for closer management and greater exposure. I see a couple of responses to the original case so far - feel free to provide updates if this is pending a resolution. Thanks for all the information so far, I hope the currently suggested docs have been helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
does this answer your question? orm Related to models, datastores, orm config, Waterline, sails-hook-orm, etc. question
Development

No branches or pull requests

7 participants