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
Function: UUID() and RAND() #198
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://en.wikipedia.org/wiki/Universally_unique_identifier
UUID is not just a random number.
You can use uuid v4 for this case.
https://docs.rs/uuid/0.8.2/uuid/
Are you referring to 128 bit ones? |
Should I perhaps rename this to |
We would need a new data type if we want to do that reasonably. |
UUID data type and UUID function is just a different independent issue. |
Exactly, which is why I have opted to make an implmentation of |
Was this issue for implementing UUID? https://tools.ietf.org/html/rfc4122
|
As mentioned in #196, MySQL implements As we have agreed this PR isn't for adding another data type thus it will not include a full length (128 bit) UUID. I am opposed to implementing UUID as Thus, shall I rename to |
Storing it as text seems very silly to me. If it is the standard perhaps GlueSQL should do it though.
Why? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, codes look really good.
Once you remove all comments then I'll approve and merge right after.
Except for user documentation purpose, I usually hate to leave comments to codes.
Both compiler and human checks the codes whether it is ok or not.
However, comments are just extra information.
Programmer needs to manage comments not to be outdated, but it is quite tough.
Codes just run and pass tests, it does not care whether comments is correct or not.
A lot of mistake happens on this comments.
Usual case is, someone update existing codes but forgets to update comments to fit to the code changes.
Then, comments contain wrong information and it becomes just a mess.
In here, the comments which you wrote are already outdated.
- inserting
RAND()
float value toINTEGER
type. id INT
withDEFAULT UUID()
These are not to blame, I just wanted to say how dangerous comments can be.
I hope that this can be helpful enough for you.
It is ok to do more talk in here.
Or if you are ok with this opinion, then you can remove all comments including // Unreliable result
.
)), | ||
), | ||
( | ||
"SELECT id FROM test WHERE RAND() > 0 AND RAND() < 1", // Unreliable result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RAND()
can be zero so it needs to be RAND() >= 0
No, because |
The issue is, the alternative to leaving comments is just to remove stuff. This way when the issues are fixed, how do we know what to re incorportate? |
If you care about this, you can register the issue on this. |
How would make such an issue, referring to an unmerged PR, reference it? |
/*
( Cannot test, see #197
"INSERT INTO test (id) VALUES (RAND()), (RAND()), (RAND()), (RAND()), (RAND())",
Ok(Payload::Insert(5)), // Should error if UUID isn't working
),
(
"INSERT INTO test (id) VALUES (RAND())",
Ok(Payload::Insert(1)), // Should error if UUID isn't working
),*/
/*( Cannot test, see #197
"CREATE TABLE test_default (id INT UNIQUE NOT NULL DEFAULT RAND())",
Ok(Payload::Create),
),
("INSERT INTO test_default (id) VALUES (NULL)", Ok(Payload::Insert(1))),
(
"SELECT 1 FROM test_default WHERE id > 0 AND id < 1", // Unreliable result
Ok(select!(
id
Value::I64;
1
)),
),*/ btw, I cannot even understand what is these comments for.
If it is clear enough then you will be able to register the issue. |
That code is essentially pseudo-code, as you said with comments, you don't get them compiled so nothing tells you to fix them. They're just showing tests that I want in very crude ways. What I'm saying is that these issues relate wholly to this PR, they would not make sense as seperate issues in the gluesql github, as there is nothing that can be done for them as the repository stands. Having said that however, once this PR is merged there will be actions that could be taken. |
Resolve: #196