MyBB Community Forums

Full Version: 1101 - BLOB, TEXT, GEOMETRY or JSON column 'preview_data' can't have a default value
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello guys,

I try to install Link-tools-1.3.2 plugin but, I give this error:

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
    1101 - BLOB, TEXT, GEOMETRY or JSON column 'preview_data' can't have a default value
Query:
    CREATE TABLE mybb_url_previews ( url_term varchar(2083) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, preview_data text NOT NULL DEFAULT '', dateline int(10) unsigned NOT NULL DEFAULT 0, valid tinyint(1) NOT NULL DEFAULT 1, previewer_class_name varchar(100) NOT NULL DEFAULT '', previewer_class_vers varchar(15) NOT NULL DEFAULT '', KEY url_term (url_term(166)) ) CHARACTER SET utf8 COLLATE utf8_general_ci;

If you're a visitor of this website, please wait a few minutes and try again. If this problem persists, please contact the site owner.

If you are the site owner, please check the MyBB Documentation for help resolving common issues, or get technical help on the MyBB Community Forums. 

I removed 'sid' => NULL line, but problem still persist.

Anyone can help me?

PS: Mybb 18.x

Thanks
Hi there. Plugin author here. Sorry about this. This error is probably due to STRICT_TRANS_TABLES being included in your database's sql_mode setting. The plugin ought to avoid this error though in any case, so it's not your fault.

I think that the plugin should probably work OK even with that DEFAULT '' after preview_data text NOT NULL being removed (in inc/plugins/linktools.php in the lkt_install_or_upgrade function). If you would be willing to remove that and test whether the plugin works OK, I would really appreciate it. If you are successful, then I can include that fix in the next release. Otherwise, we can try alternative approaches.

Thanks for your bug report!
I removed line 292 from but error still persist:

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
    1054 - Unknown column 'preview_data' in 'field list'
Query:
    SELECT valid, dateline, previewer_class_name, previewer_class_vers, preview_data FROM mybb_url_previews WHERE url_term = 'https://twitter.com/profile'

If you're a visitor of this website, please wait a few minutes and try again. If this problem persists, please contact the site owner.

If you are the site owner, please check the MyBB Documentation for help resolving common issues, or get technical help on the MyBB Community Forums. 
Laird said to remove DEFAULT '' from the line, not all the line.
  preview_data text            NOT NULL DEFAULT \'\',

change with

  preview_data,         
Probably better instead would be to change to:
  preview_data text             NULL,
Briefly tested on a local installation and seems to work OK. Let me know how you go though. And thanks Crazycat for your succinct intervention - more succinct than I would have been!
(2021-07-29, 02:01 PM)Laird Wrote: [ -> ]Probably better instead would be to change to:
  preview_data text             NULL,
Briefly tested on a local installation and seems to work OK. Let me know how you go though. And thanks Crazycat for your succinct intervention - more succinct than I would have been!

Not working fkfk

url_term     varchar('.lkt_max_url_len.') CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  preview_data text             NOT NULL DEFAULT \'\',
  dateline     int(10) unsigned NOT NULL DEFAULT 0,
  valid        tinyint(1)       NOT NULL DEFAULT 1,
  previewer_class_name varchar('.lkt_max_previewer_class_name_len.') NOT NULL DEFAULT \'\',
  previewer_class_vers varchar('.lkt_max_previewer_class_vers_len.') NOT NULL DEFAULT \'\',

Files:
Archive:  /home/site/public_html/forums/link.zip
  inflating: admin/modules/config/linkpreviewers.php  
  inflating: admin/modules/tools/linkpreviewers.php  
  inflating: images/image-placeholder-icon.png  
  inflating: inc/languages/english/admin/linktools.lang.php  
  inflating: inc/languages/english/linktools.lang.php  
  inflating: inc/plugins/linktools.php  
  inflating: inc/plugins/linktools/auto-term-links.php  
  inflating: inc/plugins/linktools/extra-curl-opts.example.php  
  inflating: inc/plugins/linktools/ignored-query-params.php  
  inflating: inc/plugins/linktools/link-previewers-3rd-party/README.md  
  inflating: inc/plugins/linktools/link-previewers-dist/LinkPreviewerDefault.php  
  inflating: inc/plugins/linktools/link-previewers-dist/LinkPreviewerPlainText.php  
  inflating: inc/plugins/linktools/link-previewers-dist/LinkPreviewerTwitterStatus.php  
  inflating: inc/plugins/linktools/link-previewers-dist/LinkPreviewerYouTubeVideo.php  
  inflating: inc/plugins/linktools/link-previewers-dist/README.md  
  inflating: inc/plugins/linktools/LinkPreviewerBase.php  
  inflating: inc/tasks/linktools.php  
  inflating: jscripts/linkpreviews.js  
  inflating: jscripts/linktools.js   
  inflating: linktools.php           
  inflating: lkt-regen-preview.php   
  inflating: lkt_search.php   

MySQL Version
5.7.35

Architecture
x86_64


PHP Version
7.3.29


Apache Version
2.4.48


That's not surprising given that according to the code you pasted, you haven't changed the relevant line at all. It is still as it was originally.

To be very clear, you need to change line 292 of inc/plugins/linktools.php from:
  preview_data text             NOT NULL DEFAULT \'\',
to:
  preview_data text             NULL,
(2021-07-29, 02:13 PM)Laird Wrote: [ -> ]That's not surprising given that according to the code you pasted, you haven't changed the relevant line at all. It is still as it was originally.

To be very clear, you need to change line 292 of inc/plugins/linktools.php from:
  preview_data text             NOT NULL DEFAULT \'\',
to:
  preview_data text             NULL,

preview_data text             NULL,
  dateline     int(10) unsigned NOT NULL DEFAULT 0,
  valid        tinyint(1)       NOT NULL DEFAULT 1,

Same

Quote:MyBB has experienced an internal SQL error and cannot continue.

SQL Error: 1054 - Unknown column 'preview_data' in 'field list' Query: SELECT valid, dateline, previewer_class_name, previewer_class_vers, preview_data FROM mybb_url_previews WHERE url_term = 'https://twitter.com/android'
(2021-07-29, 02:26 PM)Jackson5324 Wrote: [ -> ]Same

Try uninstalling and then reinstalling the plugin.
Pages: 1 2