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

Data truncated for column 'version' #1

Open
ggeerraalldd opened this issue Apr 5, 2023 · 10 comments
Open

Data truncated for column 'version' #1

ggeerraalldd opened this issue Apr 5, 2023 · 10 comments

Comments

@ggeerraalldd
Copy link

I installed the module in local/modules and ran a migration to set up my mySQL munkireport database tables.
After adding the module to my .env, I did a client installation via curl on my computer to test out the reporting.
During the first munkireport-runner process I got this error:

Server info: starting: reportdata
Server An error occurred while processing: \Mosyle_business_processor
Server Error: SQLSTATE[01000]: Warning: 1265 Data truncated for column 'version' at row 1 (SQL: insert into mosyle_business (serial_number, version, org_name, attempt_date, success_date, location_enabled) values (ABC12DE3F4, 6.12.17, ORG, 1680116506.214574, 1680116508.364317, 0))

The migration sets up 'version' as an integer. Is that going to work with '6.12.17' or does it need to be a string?

@precursorca
Copy link
Owner

precursorca commented Apr 5, 2023 via email

@ggeerraalldd
Copy link
Author

Thanks!

I just ran munkireport-runner and quickly edited the cache/mosyle_business.txt results to change "6.12.17" to "61217" and the data uploaded to the server. When I ran mr-runner again normally , it failed on version like before. It seems like the decimals are the source of my problem.

macOS 12.6.4, munkireport 5.7.1, mySQL 8.3.0, php 7.4.30

Screenshot 2023-04-05 at 3 06 16 PM

@precursorca
Copy link
Owner

precursorca commented Apr 5, 2023 via email

@ggeerraalldd
Copy link
Author

I made a new migration that used $table->dropColumn('version') and $table->string('version')->nullable(); to recreate the version column, and that fixed it in my instance.

It took a couple attempts, so don't know if it was a combination of 2 migrations, or just the last one I tried that worked. I'm brand new to the please make-migration game.

I can continue playing around with it, especially since I'm beta testing MR 5.8 on another computer, and since that db isn't in production can try more things (or start over).

@precursorca
Copy link
Owner

precursorca commented Apr 5, 2023 via email

@ggeerraalldd
Copy link
Author

Tested on MR5.8 with SQLite last night, and did not have the version error.
This morning I set up mySQL 8.0.32/PHP8.2, created munkireport db and ran migrations.
Configured a test client and connected, and it failed the same way

Server An error occurred while processing: \Mosyle_business_processor
Server Error: SQLSTATE[01000]: Warning: 1265 Data truncated for column 'version' at row 1 (Connection: default, SQL: insert into `mosyle_business` (`serial_number`, `version`, `org_name`, `attempt_date`, `success_date`, `location_enabled`) values (A1BCD23EF4GH, 6.12.17, ORG, 1680702326.924118, 1680702327.880424, 0))
Server info: starting: mosyle_business

Deleted the munkireport db, changed your migration to use

        $table->string('version')->nullable();

I created a new munkireport db in mySQL, reran migrations and had the client check in. This time it worked.

So mySQL and sqlite are treating the data differently. 6.12.17 is definitely not an integer, but sqlite accepts it anyway.

I found this when searching about INTEGER usage in sqlite, which explains why:

Introduction to SQLite data types

If you come from other database systems such as MySQL and PostgreSQL, you notice that they use static typing. It means when you declare a column with a specific data type, that column can store only data of the declared data type.

Different from other database systems, SQLite uses dynamic type system. In other words, a value stored in a column determines its data type, not the column’s data type.

@precursorca
Copy link
Owner

precursorca commented Apr 6, 2023 via email

@precursorca
Copy link
Owner

precursorca commented Apr 6, 2023 via email

@ggeerraalldd
Copy link
Author

I'm also not sure of its utility in our org. We don't use Self-Service at all and rely on munkitools for patch management and custom scripts and configurations.

Anyway, it was more enjoyable puzzling this out than installing homebrew and signing PHP for a new server...

@precursorca
Copy link
Owner

precursorca commented Apr 6, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants