Skip to content

Commit

Permalink
Allow connecting to db during handshake
Browse files Browse the repository at this point in the history
I got the test passing with an extra change_db command, which wasn't
strictly correct (I had just hard-coded the capabilities back then so it
was easier).
  • Loading branch information
composerinteralia committed Apr 23, 2024
1 parent 8fbf09e commit b713c60
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 0 additions & 1 deletion lib/nocturne.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def initialize(options = {})
@options = options
@query_flags = QUERY_FLAGS_CAST
connect
change_db(options[:database]) if options[:database]
end

def change_db(db)
Expand Down
6 changes: 4 additions & 2 deletions lib/nocturne/protocol/handshake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def server_handshake
# long_password: 1,
found_rows: 2,
# long_flag: 4,
# connect_with_db: 8,
connect_with_db: 8,
# capabilities_no_schema: 0x10,
# compress: 0x20,
# odbc: 0x40,
Expand Down Expand Up @@ -99,8 +99,9 @@ def server_handshake

def capabilities(ssl: false)
cap = DEFAULT_CAPABILITES
cap |= CAPABILITIES[:ssl] if ssl
cap |= CAPABILITIES[:found_rows] if @options[:found_rows]
cap |= CAPABILITIES[:connect_with_db] if @options[:database]
cap |= CAPABILITIES[:ssl] if ssl
cap
end

Expand Down Expand Up @@ -133,6 +134,7 @@ def client_handshake
packet.int8(0)
end

packet.nulstr(@options[:database]) if @options[:database]
packet.nulstr(@auth_plugin_name)
end
end
Expand Down

0 comments on commit b713c60

Please sign in to comment.