in jones-ndb/impl/src/ndb/DBDictionaryImpl.cpp [624:729]
Handle<Object> GetTableCall::buildDBColumn(const NdbDictionary::Column *col) {
EscapableHandleScope scope(isolate);
Local<Object> obj = NdbDictColumnEnv.wrap(col)->ToObject();
NdbDictionary::Column::Type col_type = col->getType();
bool is_int = (col_type <= NDB_TYPE_BIGUNSIGNED);
bool is_dec = ((col_type == NDB_TYPE_DECIMAL) || (col_type == NDB_TYPE_DECIMALUNSIGNED));
bool is_binary = ((col_type == NDB_TYPE_BLOB) || (col_type == NDB_TYPE_BINARY)
|| (col_type == NDB_TYPE_VARBINARY) || (col_type == NDB_TYPE_LONGVARBINARY));
bool is_char = ((col_type == NDB_TYPE_CHAR) || (col_type == NDB_TYPE_TEXT)
|| (col_type == NDB_TYPE_VARCHAR) || (col_type == NDB_TYPE_LONGVARCHAR));
bool is_lob = ((col_type == NDB_TYPE_BLOB) || (col_type == NDB_TYPE_TEXT));
/* Required Properties */
SET_RO_PROPERTY(obj, SYMBOL(isolate, "name"),
String::NewFromUtf8(isolate, col->getName()));
SET_RO_PROPERTY(obj, SYMBOL(isolate, "columnNumber"),
v8::Int32::New(isolate, col->getColumnNo()));
SET_RO_PROPERTY(obj, SYMBOL(isolate, "columnType"),
String::NewFromUtf8(isolate, getColumnType(col)));
SET_RO_PROPERTY(obj, SYMBOL(isolate, "isIntegral"),
Boolean::New(isolate, is_int));
SET_RO_PROPERTY(obj, SYMBOL(isolate, "isNullable"),
Boolean::New(isolate, col->getNullable()));
SET_RO_PROPERTY(obj, SYMBOL(isolate, "isInPrimaryKey"),
Boolean::New(isolate, col->getPrimaryKey()));
SET_RO_PROPERTY(obj, SYMBOL(isolate, "columnSpace"),
v8::Int32::New(isolate, col->getSizeInBytes()));
/* Implementation-specific properties */
SET_RO_PROPERTY(obj, SYMBOL(isolate, "ndbTypeId"),
v8::Int32::New(isolate, static_cast<int>(col->getType())));
SET_PROPERTY(obj, SYMBOL(isolate, "ndbRawDefaultValue"),
getDefaultValue(isolate, col), v8::ReadOnly);
if(is_lob) {
SET_RO_PROPERTY(obj, SYMBOL(isolate, "ndbInlineSize"),
v8::Int32::New(isolate, col->getInlineSize()));
SET_RO_PROPERTY(obj, SYMBOL(isolate, "ndbPartSize"),
v8::Int32::New(isolate, col->getPartSize()));
}
/* Optional Properties, depending on columnType */
/* Group A: Numeric */
if(is_int || is_dec) {
SET_RO_PROPERTY(obj, SYMBOL(isolate, "isUnsigned"),
Boolean::New(isolate, getIntColumnUnsigned(col)));
}
if(is_int) {
SET_RO_PROPERTY(obj, SYMBOL(isolate, "intSize"),
v8::Int32::New(isolate, col->getSizeInBytes()));
}
if(is_dec) {
SET_RO_PROPERTY(obj, SYMBOL(isolate, "scale"),
v8::Int32::New(isolate, col->getScale()));
SET_RO_PROPERTY(obj, SYMBOL(isolate, "precision"),
v8::Int32::New(isolate, col->getPrecision()));
}
SET_RO_PROPERTY(obj, SYMBOL(isolate, "isAutoincrement"),
Boolean::New(isolate, col->getAutoIncrement()));
/* Group B: Non-numeric */
if(is_binary || is_char) {
SET_RO_PROPERTY(obj, SYMBOL(isolate, "isBinary"),
Boolean::New(isolate, is_binary));
SET_RO_PROPERTY(obj, SYMBOL(isolate, "isLob"),
Boolean::New(isolate, is_lob));
if(is_binary) {
SET_RO_PROPERTY(obj, SYMBOL(isolate, "length"),
v8::Int32::New(isolate, col->getLength()));
}
if(is_char) {
const EncoderCharset * csinfo = getEncoderCharsetForColumn(col);
SET_RO_PROPERTY(obj, SYMBOL(isolate, "length"),
v8::Int32::New(isolate, col->getLength() / csinfo->maxlen));
SET_RO_PROPERTY(obj, SYMBOL(isolate, "charsetName"),
String::NewFromUtf8(isolate, csinfo->name));
SET_RO_PROPERTY(obj, SYMBOL(isolate, "collationName"),
String::NewFromUtf8(isolate, csinfo->collationName));
}
}
return scope.Escape(obj);
}