• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 2.0 Incorrect integer value: '' for column 'addon_columm' at row 1 in src\XF\Db\AbstractStatement.php

jmurrayhead

Well-known member
#1
As the subject suggests, I get this error:

XF\Db\Exception: MySQL query error [1366]: Incorrect integer value: '' for column 'addon_column' at row 1 in src\XF\Db\AbstractStatement.php at line 183

This is an int field, signed (because negative values), with a default of 0. What I've researched suggests turning off STRICT mode, but is that really the right way to go? Surely we can't expect everyone to be able to change this setting, particularly in hosted environments.

Thanks
 

Chris D

XenForo developer
Staff member
#2
I don't necessarily think anything needs to change with the way you've set up the field column.

What are you doing to get this error? The error suggests you are setting a value of '' (empty string). I assume your code is setting that value somewhere rather than it being the default value.
 

jmurrayhead

Well-known member
#3
I don't necessarily think anything needs to change with the way you've set up the field column.

What are you doing to get this error? The error suggests you are setting a value of '' (empty string). I assume your code is setting that value somewhere rather than it being the default value.
I was setting it to 0 via the extended Creator. However, I had incorrectly named the column in the Listener and found a couple other errors on my way there. Once corrected, everything works as expected.

Perhaps I should put down the wine glass while doing this...

nah..:p
 

jmurrayhead

Well-known member
#4
Chris, since I have your attention, when extending a Creator class, such as XF\Service\Thread\Creator, I'm assuming, this only runs when initially creating a thread. Is that a correct assumption? So whatever I do here, such as the following, would only affect the first post on creation of the thread and not during a reply?

PHP:
        $post = $thread->getRelationOrDefault('FirstPost');
        $post->save();

        $post->fastUpdate('addon_column1', 0);    
        $post->fastUpdate('addon_column2', []);
 

jmurrayhead

Well-known member
#6
Correct. One of the great things about the service approach. The roles and responsibilities of certain code is much clearer.
Thanks, appreciate it. I've built service oriented architectures myself and wholeheartedly agree with that statement.

You all really did an amazing job with this rewrite. I may ask a lot of stupid questions over the next few months because this is so different to what I'm used to in the C#/.NET world, but what I'm seeing so far is so well organized and well thought out. If we don't get an explosion of addons for 2.0 I'll be really surprised.