• <i id='FehtP'><tr id='FehtP'><dt id='FehtP'><q id='FehtP'><span id='FehtP'><b id='FehtP'><form id='FehtP'><ins id='FehtP'></ins><ul id='FehtP'></ul><sub id='FehtP'></sub></form><legend id='FehtP'></legend><bdo id='FehtP'><pre id='FehtP'><center id='FehtP'></center></pre></bdo></b><th id='FehtP'></th></span></q></dt></tr></i><div id='FehtP'><tfoot id='FehtP'></tfoot><dl id='FehtP'><fieldset id='FehtP'></fieldset></dl></div>

    <legend id='FehtP'><style id='FehtP'><dir id='FehtP'><q id='FehtP'></q></dir></style></legend>

    1. <small id='FehtP'></small><noframes id='FehtP'>

        <tfoot id='FehtP'></tfoot>

          <bdo id='FehtP'></bdo><ul id='FehtP'></ul>
      1. 如何在 Rails 中关闭 MySQL 严格模式

        时间:2023-10-26

          <tbody id='Q9Qbw'></tbody>

        1. <small id='Q9Qbw'></small><noframes id='Q9Qbw'>

          <legend id='Q9Qbw'><style id='Q9Qbw'><dir id='Q9Qbw'><q id='Q9Qbw'></q></dir></style></legend>
          • <i id='Q9Qbw'><tr id='Q9Qbw'><dt id='Q9Qbw'><q id='Q9Qbw'><span id='Q9Qbw'><b id='Q9Qbw'><form id='Q9Qbw'><ins id='Q9Qbw'></ins><ul id='Q9Qbw'></ul><sub id='Q9Qbw'></sub></form><legend id='Q9Qbw'></legend><bdo id='Q9Qbw'><pre id='Q9Qbw'><center id='Q9Qbw'></center></pre></bdo></b><th id='Q9Qbw'></th></span></q></dt></tr></i><div id='Q9Qbw'><tfoot id='Q9Qbw'></tfoot><dl id='Q9Qbw'><fieldset id='Q9Qbw'></fieldset></dl></div>
            • <tfoot id='Q9Qbw'></tfoot>
                • <bdo id='Q9Qbw'></bdo><ul id='Q9Qbw'></ul>

                  本文介绍了如何在 Rails 中关闭 MySQL 严格模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  升级到 Rails 4,现在似乎默认情况下为 Rails 连接启用了 MySQL 严格模式.我这样说是因为我的 Rails 应用程序在保存长度超过 255 个字符的字符串值时收到Mysql2::Error: Data too long for column".然而,我将相同的查询粘贴到 MySQL 控制台(据报告全局严格模式已关闭)并且它工作正常,只是有截断警告.作为进一步的证据,它在这里说 "Rails 4 默认都使用严格模式".

                  Upgrading to Rails 4, it seems MySQL strict mode is now on by default for Rails connections. I say this because my Rails app is getting "Mysql2::Error: Data too long for column" when saving a string value longer than 255 characters. Yet, I paste the same query into MySQL console (where global strict mode is reported to be off) and it works fine, just with truncation warnings. As further evidence, it says here "Rails 4 both use strict mode by default".

                  我的问题是如何从 Rails 应用程序中关闭严格模式?我宁愿避免立即升级所有内容以支持它.

                  My question is how can I turn strict mode off from the Rails app? I'd rather avoid upgrading everything to support it right now.

                  推荐答案

                  您可以在 database.yml 中使用 strict: false 设置严格模式,如下所示:

                  You can set strict mode in your database.yml using strict: false as follows:

                  production:
                    host: ...
                    username: ...
                    strict: false
                  

                  https://api.rubyonrails.org/v4.2.8/classes/ActiveRecord/ConnectionAdapters/MysqlAdapter.html

                  这篇关于如何在 Rails 中关闭 MySQL 严格模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何将数据从 ASCII (ISO/IEC 8859-1) 导入 Rails/PGSQL 数据库? 下一篇:尝试更新 mySQL 中的 640k 行会出现“查询期间与 MySQL 服务器的连接丢失"

                  相关文章

                    <bdo id='5u8IG'></bdo><ul id='5u8IG'></ul>

                    1. <small id='5u8IG'></small><noframes id='5u8IG'>

                    2. <tfoot id='5u8IG'></tfoot>
                      <i id='5u8IG'><tr id='5u8IG'><dt id='5u8IG'><q id='5u8IG'><span id='5u8IG'><b id='5u8IG'><form id='5u8IG'><ins id='5u8IG'></ins><ul id='5u8IG'></ul><sub id='5u8IG'></sub></form><legend id='5u8IG'></legend><bdo id='5u8IG'><pre id='5u8IG'><center id='5u8IG'></center></pre></bdo></b><th id='5u8IG'></th></span></q></dt></tr></i><div id='5u8IG'><tfoot id='5u8IG'></tfoot><dl id='5u8IG'><fieldset id='5u8IG'></fieldset></dl></div>
                      <legend id='5u8IG'><style id='5u8IG'><dir id='5u8IG'><q id='5u8IG'></q></dir></style></legend>