Skip to content

Instantly share code, notes, and snippets.

@thehesiod
thehesiod / freeze_time.sql
Created May 20, 2020 09:41
fake/mock now on postgres DB
-- inspiration from https://dba.stackexchange.com/questions/69988/how-can-i-fake-inet-client-addr-for-unit-tests-in-postgresql/70009#70009
CREATE SCHEMA if not exists override;
create table if not exists override.freeze_time_param_type
(
param_type text not null primary key
);
insert into override.freeze_time_param_type values ('enabled'), ('timestamp'), ('tick') on conflict do nothing;
@tternquist
tternquist / ml-permissions-role-name.xqy
Created December 22, 2016 22:41
Get role name and permissions for MarkLogic document
import module namespace sec="http://marklogic.com/xdmp/security" at
"/MarkLogic/security.xqy";
declare function local:document-get-permissions($uri) {
xdmp:document-get-permissions($uri) !
xdmp:invoke-function(function() {
element role {.,
sec:get-role-names(xs:unsignedLong(.//sec:role-id ))
}
},<options xmlns="xdmp:eval"><database>{xdmp:database("Security")}</database></options>)
};