MCPcopy Create free account
hub / github.com/dataease/SQLBot / getSysVariableValue

Function getSysVariableValue

backend/apps/datasource/crud/row_permission.py:219–257  ·  view source on GitHub ↗
(sys_variable: SystemVariable, current_user: CurrentUser, ds: CoreDatasource, field: CoreField,
                        item: Dict, )

Source from the content-addressed store, hash-verified

217
218
219def getSysVariableValue(sys_variable: SystemVariable, current_user: CurrentUser, ds: CoreDatasource, field: CoreField,
220 item: Dict, ):
221 v = None
222 if sys_variable.value[0] == 'name':
223 v = current_user.name
224 if sys_variable.value[0] == 'account':
225 v = current_user.account
226 if sys_variable.value[0] == 'email':
227 v = current_user.email
228
229 whereValue = ''
230 if item['term'] == 'null':
231 whereValue = ''
232 elif item['term'] == 'not_null':
233 whereValue = ''
234 elif item['term'] == 'empty':
235 whereValue = "''"
236 elif item['term'] == 'not_empty':
237 whereValue = "''"
238 elif item['term'] == 'in' or item['term'] == 'not in':
239 if ds.type == 'sqlServer' and (
240 field.field_type == 'nchar' or field.field_type == 'NCHAR' or field.field_type == 'nvarchar' or field.field_type == 'NVARCHAR'):
241 whereValue = f"(N'{v}')"
242 else:
243 whereValue = f"('{v}')"
244 elif item['term'] == 'like' or item['term'] == 'not like':
245 if ds.type == 'sqlServer' and (
246 field.field_type == 'nchar' or field.field_type == 'NCHAR' or field.field_type == 'nvarchar' or field.field_type == 'NVARCHAR'):
247 whereValue = f"N'%{v}%'"
248 else:
249 whereValue = f"'%{v}%'"
250 else:
251 if ds.type == 'sqlServer' and (
252 field.field_type == 'nchar' or field.field_type == 'NCHAR' or field.field_type == 'nvarchar' or field.field_type == 'NVARCHAR'):
253 whereValue = f"N'{v}'"
254 else:
255 whereValue = f"'{v}'"
256
257 return whereValue

Callers 1

transTreeItemFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected