@@ -39,6 +39,42 @@ local function buildSQLiteSchemaTable()
3939 return SQLiteSchema
4040end
4141
42+ if SERVER then
43+ util .AddNetworkString (" blobsProfiler:SQLite_Schema_CreateSQL" )
44+
45+ net .Receive (" blobsProfiler:SQLite_Schema_CreateSQL" , function (len , ply )
46+ if not blobsProfiler .CanAccess (ply , " SQLite" ) then return end
47+ if not blobsProfiler .CanAccess (ply , " SQLite_Schema" ) then return end
48+ if not blobsProfiler .CanAccess (ply , " SQLite_Schema_CreateSQL" ) then return end
49+
50+ local tableName = net .ReadString ()
51+ local rcAction = net .ReadUInt (2 )
52+ local grabData = sql .QueryValue (" SELECT sql FROM sqlite_master WHERE name = " .. sql .SQLStr (tableName ) .. " LIMIT 1;" )
53+
54+ if grabData then
55+ net .Start (" blobsProfiler:SQLite_Schema_CreateSQL" )
56+ net .WriteString (grabData )
57+ net .WriteUInt (rcAction , 2 )
58+ net .Send (ply )
59+ end
60+ end )
61+ else
62+ net .Receive (" blobsProfiler:SQLite_Schema_CreateSQL" , function ()
63+ local createSQL = net .ReadString ()
64+ local rcAction = net .ReadUInt (2 )
65+
66+ if rcAction == 1 then
67+ print (createSQL )
68+
69+ Derma_Message (" SQLite creation statement printed to console" , " blobsProfiler: SQLite Schema - Create SQL" , " OK" )
70+ elseif rcAction == 2 then
71+ SetClipboardText (createSQL )
72+
73+ Derma_Message (" SQLite creation statement copied to clipboard" , " blobsProfiler: SQLite Schema - Create SQL" , " OK" )
74+ end
75+ end )
76+ end
77+
4278blobsProfiler .RegisterSubModule (" SQLite" , " Schema" , {
4379 Icon = " icon16/database_gear.png" ,
4480 OrderPriority = 1 ,
@@ -68,17 +104,35 @@ blobsProfiler.RegisterSubModule("SQLite", "Schema", {
68104 submenu = {
69105 {
70106 name = " Print" ,
71- func = function (ref , node )
72- local grabSQLCreate = sql .QueryValue (" SELECT sql FROM sqlite_master WHERE name = " .. sql .SQLStr (ref .key ) .. " LIMIT 1;" )
73- print (grabSQLCreate )
107+ func = function (ref , node , luaState )
108+ if luaState == " Client" then
109+ local grabSQLCreate = sql .QueryValue (" SELECT sql FROM sqlite_master WHERE name = " .. sql .SQLStr (ref .key ) .. " LIMIT 1;" )
110+ print (grabSQLCreate )
111+
112+ Derma_Message (" SQLite creation statement printed to console" , " blobsProfiler: SQLite Schema - Create SQL" , " OK" )
113+ else
114+ net .Start (" blobsProfiler:SQLite_Schema_CreateSQL" )
115+ net .WriteString (ref .key )
116+ net .WriteUInt (1 , 2 )
117+ net .SendToServer ()
118+ end
74119 end ,
75120 icon = " icon16/application_osx_terminal.png"
76121 },
77122 {
78123 name = " Copy to clipboard" ,
79- func = function (ref , node )
80- local grabSQLCreate = sql .QueryValue (" SELECT sql FROM sqlite_master WHERE name = " .. sql .SQLStr (ref .key ) .. " LIMIT 1;" )
81- SetClipboardText (grabSQLCreate )
124+ func = function (ref , node , luaState )
125+ if luaState == " Client" then
126+ local grabSQLCreate = sql .QueryValue (" SELECT sql FROM sqlite_master WHERE name = " .. sql .SQLStr (ref .key ) .. " LIMIT 1;" )
127+ SetClipboardText (grabSQLCreate )
128+
129+ Derma_Message (" SQLite creation statement copied to clipboard" , " blobsProfiler: SQLite Schema - Create SQL" , " OK" )
130+ else
131+ net .Start (" blobsProfiler:SQLite_Schema_CreateSQL" )
132+ net .WriteString (ref .key )
133+ net .WriteUInt (2 , 2 )
134+ net .SendToServer ()
135+ end
82136 end ,
83137 icon = " icon16/page_copy.png"
84138 }
0 commit comments