Skip to content

Commit

Permalink
windows: avoid breaking Libc.getuid call
Browse files Browse the repository at this point in the history
  • Loading branch information
will committed Oct 31, 2024
1 parent cafe0f9 commit cafeb76
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/pq/conninfo.cr
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,13 @@ module PQ
end

private def current_user_name
System::User.find_by(id: LibC.getuid.to_s).username
{% if flag?(:windows) %}
# NOTE: actually getting the current username on windows would be better
# https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getusernamew
"crystal"
{% else %}
System::User.find_by(id: LibC.getuid.to_s).username
{% end %}
end
end
end

0 comments on commit cafeb76

Please sign in to comment.