Skip to content
Browse files

add role #6

  • Loading branch information...
1 parent 8a86562 commit 5742cd759fa4242eb9d3c3dc24a851781ee2ccf9 @hgourvest committed Sep 28, 2012
Showing with 13 additions and 6 deletions.
  1. +11 −5 lib/index.js
  2. +2 −1 test/test.js
View
16 lib/index.js
@@ -1069,12 +1069,12 @@ exports.create = function(host, port, database, user, password, pageSize, callba
}, error);
};
-exports.attachOrCreate = function(host, port, database, user, password, pageSize, callback, error) {
+exports.attachOrCreate = function(host, port, database, user, password, pageSize, role, callback, error) {
var cnx = this.connection = new Connection(host, port);
cnx.connect(database, function(ret){
if (!ret.status) {
- cnx.attach(database, user, password, callback, function() {
- cnx.createDatabase(database, user, password, pageSize, callback, error);
+ cnx.attach(database, user, password, role, callback, function() {
+ cnx.createDatabase(database, user, password, pageSize, role, callback, error);
});
} else {
doCallback(ret, callback, error)
@@ -1260,7 +1260,7 @@ Connection.prototype.connect = function (filename, callback, error) {
};
-Connection.prototype.attach = function (filename, user, password, callback, error) {
+Connection.prototype.attach = function (filename, user, password, role, callback, error) {
var msg = this._msg;
var blr = this._blr;
msg.pos = 0;
@@ -1270,6 +1270,9 @@ Connection.prototype.attach = function (filename, user, password, callback, erro
blr.addString(isc_dpb_lc_ctype, 'UTF8', DEFAULT_ENCODING);
blr.addString(isc_dpb_user_name, user, DEFAULT_ENCODING);
blr.addString(isc_dpb_password, password, DEFAULT_ENCODING);
+ if (role) {
+ blr.addString(isc_dpb_sql_role_name, role, DEFAULT_ENCODING);
+ }
msg.addInt(op_attach);
msg.addInt(0); // Database Object ID
@@ -1297,14 +1300,17 @@ Connection.prototype.detach = function (callback, error) {
}, error);
};
-Connection.prototype.createDatabase = function (filename, user, password, pageSize, callback, error) {
+Connection.prototype.createDatabase = function (filename, user, password, pageSize, role, callback, error) {
var blr = this._blr;
blr.pos = 0;
blr.addByte(1);
blr.addString(isc_dpb_set_db_charset, 'UTF8', DEFAULT_ENCODING);
blr.addString(isc_dpb_lc_ctype, 'UTF8', DEFAULT_ENCODING);
blr.addString(isc_dpb_user_name, user, DEFAULT_ENCODING);
blr.addString(isc_dpb_password, password, DEFAULT_ENCODING);
+ if (role) {
+ blr.addString(isc_dpb_sql_role_name, role, DEFAULT_ENCODING);
+ }
blr.addNumeric(isc_dpb_sql_dialect, 3);
blr.addNumeric(isc_dpb_force_write, 1);
blr.addNumeric(isc_dpb_overwrite, 1);
View
3 test/test.js
@@ -9,6 +9,7 @@ host = '127.0.0.1';
port = 3050;
user = 'SYSDBA';
password = 'masterkey';
+role = null;
pagesize = 4096;
quit = function() {
@@ -151,7 +152,7 @@ test5 = function() {
repl.start("");
-fb.attachOrCreate(host, port, db, user, password, pagesize,
+fb.attachOrCreate(host, port, db, user, password, pagesize, role,
function (db) {
database = db;
test1();

0 comments on commit 5742cd7

Please sign in to comment.
Something went wrong with that request. Please try again.