Skip to content

Information mandatory field #798

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

Closed
webjoel opened this issue Apr 25, 2014 · 7 comments
Closed

Information mandatory field #798

webjoel opened this issue Apr 25, 2014 · 7 comments
Labels

Comments

@webjoel
Copy link

webjoel commented Apr 25, 2014

In the results of query part "fields" not return information for mandatory field join others information of field.

@dougwilson
Copy link
Member

I'm not sure what you're asking for. The fields is an array of field packets. Which column are you talking about in the the packet (see http://dev.mysql.com/doc/internals/en/com-query-response.html#column-definition)?

@webjoel
Copy link
Author

webjoel commented Apr 25, 2014

Sorry, I would like to know if you know whether a field accepts null or not. In this case this information would need to come together with other field information in the information fields result.

@dougwilson
Copy link
Member

I would like to know if you know whether a field accepts null or not.

which column would this be in the packet I linked to?

In this case this information would need to come together with other field information in the information fields result.

I'm not sure what this means.

@webjoel
Copy link
Author

webjoel commented Apr 25, 2014

Sorry for my english...

In "Protocol::ColumnDefinition41", there is the possibility of whether a field accepts null values​​? By Not Null option.

@webjoel
Copy link
Author

webjoel commented Apr 25, 2014

By example:

With SQL command "SHOW COLUMNS FROM tablename" I can get the information if the field accepts null values ​​or not.

@dougwilson
Copy link
Member

Gotcha. Yes, you can tell:

connection.query('SELECT col1 FROM my_table', function(err, rows, fields){
  if (err) throw err;
  var nullable = !(fields[0].flags & 0x01);
  console.log('col1 can' + (nullable ? '' : ' not') + ' be null');
});

It should probably be easier, or at the very least, not require you to know that the first bit of the flag means the field it not nullable.

@webjoel
Copy link
Author

webjoel commented Apr 25, 2014

ok.

Thank´s!

@webjoel webjoel closed this as completed Apr 25, 2014
dveeden pushed a commit to dveeden/mysql that referenced this issue Jan 31, 2023
* travis: add mysql 8.0 env

* travis: disable version check for mysql 8
debian does not have a compatible client yet

* travis: set local-infile=1

* travis: try to fix waiting for mysql 8 and optimize wait time

* travis: show output of wait script

* travis: grep for successful execution

* travis: remove sleep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants