Fix: Handle potential undefined values in LDAP query builder and database queries.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 705f2157-ef97-4fbd-89e4-8c7f2ecaea90
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7ed01c5f-a82d-405a-b728-b2e3d127c60c/e6f1810b-5d83-4907-ac49-d7d4e6aaf193.jpg
This commit is contained in:
alphaeusmote
2025-04-09 01:02:31 +00:00
parent f7908467b7
commit e27da69dd8
2 changed files with 14 additions and 14 deletions
+6 -6
View File
@@ -80,28 +80,28 @@ const LdapQueryBuilderPage = () => {
// Query to get LDAP connections
const {
data: connections,
data: connections = [],
isLoading: connectionsLoading
} = useQuery({
} = useQuery<LdapConnection[]>({
queryKey: ["/api/ldap-connections"],
enabled: !!user
});
// Query to get LDAP filters for the selected connection
const {
data: filters,
data: filters = [],
isLoading: filtersLoading
} = useQuery({
} = useQuery<LdapFilter[]>({
queryKey: ["/api/connections", selectedConnectionId, "ldap-filters"],
enabled: !!selectedConnectionId,
});
// Query to get LDAP filter revisions
const {
data: revisions,
data: revisions = [],
isLoading: revisionsLoading,
refetch: refetchRevisions
} = useQuery({
} = useQuery<LdapFilterRevision[]>({
queryKey: ["/api/ldap-filters", selectedFilter?.id, "revisions"],
enabled: !!selectedFilter?.id && showRevisionsDialog,
});
+8 -8
View File
@@ -590,12 +590,12 @@ export class DatabaseStorage implements IStorage {
// Apply where conditions if any
if (whereClause) {
baseQuery = baseQuery.where(whereClause);
baseQuery = baseQuery.where(whereClause as any);
}
// Apply ordering if any
if (orderClauses.length > 0) {
baseQuery = baseQuery.orderBy(...orderClauses);
if (orderClauses && orderClauses.length > 0) {
baseQuery = baseQuery.orderBy(...(orderClauses as any[]));
}
// Apply pagination if specified
@@ -611,7 +611,7 @@ export class DatabaseStorage implements IStorage {
const users = await baseQuery;
// Handle field selection if specified
if (selectedFields.length > 0) {
if (selectedFields && selectedFields.length > 0) {
const result = users.map(user => {
const filtered: Partial<AdUser> = { id: user.id };
selectedFields.forEach(field => {
@@ -679,12 +679,12 @@ export class DatabaseStorage implements IStorage {
// Apply where conditions if any
if (whereClause) {
baseQuery = baseQuery.where(whereClause);
baseQuery = baseQuery.where(whereClause as any);
}
// Apply ordering if any
if (orderClauses.length > 0) {
baseQuery = baseQuery.orderBy(...orderClauses);
if (orderClauses && orderClauses.length > 0) {
baseQuery = baseQuery.orderBy(...(orderClauses as any[]));
}
// Apply pagination if specified
@@ -700,7 +700,7 @@ export class DatabaseStorage implements IStorage {
const groups = await baseQuery;
// Handle field selection if specified
if (selectedFields.length > 0) {
if (selectedFields && selectedFields.length > 0) {
const result = groups.map(group => {
const filtered: Partial<AdGroup> = { id: group.id };
selectedFields.forEach(field => {