Method: Amalgalite::SQLite3::Database#table_column_metadata
- Defined in:
- ext/amalgalite/c/amalgalite_database.c
#table_column_metadata(db_name, table_name, column_name) ⇒ Hash
Returns a hash containing the meta information about the column. The available keys are:
- declared_data_type
-
the declared data type of the column
- collation_sequence_name
-
the name of the collation sequence for the column
- not_null_constraint
-
True if the column has a NOT NULL constraint
- primary_key
-
True if the column is part of a primary key
- auto_increment
-
True if the column is AUTO INCREMENT
1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 |
# File 'ext/amalgalite/c/amalgalite_database.c', line 1044 VALUE (VALUE self, VALUE db_name, VALUE tbl_name, VALUE col_name) { am_sqlite3 *am_db; int rc; /* input */ const char *zDbName = StringValuePtr( db_name ); const char *zTableName = StringValuePtr( tbl_name ); const char *zColumnName = StringValuePtr( col_name ); /* output */ const char *pzDataType = NULL; const char *pzCollSeq = NULL; int pNotNull, pPrimaryKey, pAutoinc; VALUE rHash = rb_hash_new(); VALUE rStr = Qnil; Data_Get_Struct(self, am_sqlite3, am_db); rc = ( am_db->db, zDbName, zTableName, zColumnName, &pzDataType, &pzCollSeq, &pNotNull, &pPrimaryKey, &pAutoinc); if ( SQLITE_OK != rc ) { rb_raise(eAS_Error, "Failure retrieveing column meta data for table '%s' column '%s' : [SQLITE_ERROR %d] : %s\n", zTableName, zColumnName, rc, sqlite3_errmsg( am_db-> db )); } rStr = ( NULL == pzDataType) ? Qnil : rb_str_new2( pzDataType ); rb_hash_aset( rHash, rb_str_new2("declared_data_type"), rStr ); rStr = ( NULL == pzCollSeq) ? Qnil : rb_str_new2( pzCollSeq ); rb_hash_aset( rHash, rb_str_new2("collation_sequence_name"), rStr ); rb_hash_aset( rHash, rb_str_new2("not_null_constraint"), ( pNotNull ? Qtrue : Qfalse )); rb_hash_aset( rHash, rb_str_new2("primary_key"), ( pPrimaryKey ? Qtrue : Qfalse )); rb_hash_aset( rHash, rb_str_new2("auto_increment"), ( pAutoinc ? Qtrue : Qfalse )); return rHash; } |