Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Original code assumed that all string objects in the format of a UUID we... #122

Merged
merged 1 commit into from

3 participants

@azweb76

We upgraded to the latest version and our code failed because we store an ID which looks like a UUID, but is text. Can you review the changes and if ok, please merge into master? Thanks, Dan

@azweb76 azweb76 Original code assumed that all string objects in the format of a UUID…
… were associated with a UUID data type. Replaced with UUID object check.
26994aa
@devdazed
Owner

I see where this can cause issue, however, the primary concern I have with this is that it may cause issues with those that aren't explicitly using the UUID type, rather using strings. Anyone else want to chime in?

@azweb76

Hi devdazed, thanks for responding so quickly. Can you think of another way to identify the value being passed in is a UUID? I know many DB providers use the data type of the value to determine the type of encoding or mapping to the underlying DB data type. Thanks

@azweb76

Any word on this? We are currently passing in text that looks like a UUID, and the query is failing.

@asilvas

@devdazed This "feature" is a bug imo. Auto-converting strings that happen to contain a UUID to a UUID is rather concerning as it is against our will. Keys can be anything, and I'd rather avoid having our data type changed from what we're storing it as. Effectively we're saying "this is our schema", but the helenus does "but we'll auto-convert these for you!".

@devdazed devdazed merged commit cbc07d9 into simplereach:master
@devdazed
Owner

Sounds good to me. I'll bump & release.

@asilvas

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 14, 2013
  1. @azweb76

    Original code assumed that all string objects in the format of a UUID…

    azweb76 authored
    … were associated with a UUID data type. Replaced with UUID object check.
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 11 deletions.
  1. +6 −11 lib/connection.js
View
17 lib/connection.js
@@ -6,7 +6,8 @@ var util = require('util'),
Row = require('./row'),
zlib = require('zlib'),
Keyspace = require('./keyspace'),
- errors = require('./errors');
+ errors = require('./errors'),
+ uuid = require('./uuid');
/**
* A No-Operation function for default callbacks
@@ -93,14 +94,13 @@ function escapeCQL(val) {
return 'NULL';
}
- // https://github.com/simplereach/helenus/issues/98
- if (typeof val === 'string' && val.match(/\w{8}\-\w{4}\-\w{4}\-\w{4}\-\w{12}/)) {
- return val;
- }
-
if(val instanceof Buffer){
return val.toString('hex');
}
+
+ if(val instanceof uuid.UUID){
+ return val.toString();
+ }
if(typeof val === 'number' || typeof val === 'boolean'){
return val.toString();
@@ -111,11 +111,6 @@ function escapeCQL(val) {
return sanitized.join(',');
}
- // https://github.com/simplereach/helenus/issues/98
- if (typeof val === 'string' && val.match(/\w{8}\-\w{4}\-\w{4}\-\w{4}\-\w{12}/)) {
- return val;
- }
-
if (typeof val === 'object' && typeof val.hex) {
return val.toString();
}
Something went wrong with that request. Please try again.