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

Table with wrong data type could be created #157

Closed
KES777 opened this issue Apr 8, 2023 · 1 comment
Closed

Table with wrong data type could be created #157

KES777 opened this issue Apr 8, 2023 · 1 comment

Comments

@KES777
Copy link
Contributor

KES777 commented Apr 8, 2023

How to reproduce: put space before type.

--- a/lib/Schema/Result/Document.pm
+++ b/lib/Schema/Result/Document.pm
@@ -21,7 +21,7 @@ $X->add_columns(
 		is_nullable =>  1,
 	},
 	document_type_id => {
-		data_type =>  'integer',
+		data_type =>  ' integer',
 	},
 	docn => {
 		data_type =>  'varchar',

Generated migration script (Notice extra space before integer for document_type_id column):

CREATE TABLE "document" (
  "id" serial NOT NULL,
  "owner_id" integer,
  "document_type_id"  integer NOT NULL,
  PRIMARY KEY ("id")
);

I do not know how long this wrong data type lurking at production code. But we noticed it when started to use 'Mojolicious::Plugin::GraphQL', which issues 'document_type_id' unknown data type: integer error.

PS. In theory we can create { data_type => 'integer NOT NULL' } and this will works.
Should we put quotes around data type to be more safe?

@KES777 KES777 changed the title Table with wrong type could be created Table with wrong data type could be created Apr 8, 2023
@rabbiveesh
Copy link
Contributor

Hi;
this looks like a bug in your code; i think the only sensible thing to do is allow the end user to pass through whatever they need.

I see that you raised this against the DBIC converter for GraphQL; that clearly takes the value straight out of DBIC. I don't even think it's a bug there, either.

You just need to not have typos in your code

@rabbiveesh rabbiveesh closed this as not planned Won't fix, can't repro, duplicate, stale Apr 13, 2023
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