Protected _sqlProtected cascadeTracks cascade delete dependencies between entities. Key: Entity ID whose update/delete SP is called by other entities' delete SPs Value: Set of Entity IDs that have CascadeDeletes=true and call this entity's update/delete SP
Protected entitiesTracks entities that need their delete stored procedures regenerated due to cascade dependencies
Protected entitiesArray of entity names that qualify for forced regeneration based on the whereClause filter
Protected filterFlag indicating whether to filter entities for forced regeneration based on entityWhereClause
Protected orderedOrdered list of entity IDs for delete SP regeneration (dependency order)
Protected analyzeAnalyzes cascade delete dependencies without generating SQL. This method only tracks which entities depend on others for cascade operations.
Protected buildBuilds a complete map of cascade delete dependencies by analyzing all entities. This method populates the cascadeDeleteDependencies map without generating SQL.
Protected buildProtected buildProtected createProtected createProtected createProtected detectDetects self-referential foreign keys in an entity (e.g., ParentTaskID pointing back to Task table) Returns array of field info objects representing recursive relationships
Protected formatFormats a default value for use in SQL, handling special cases like SQL functions
The default value from the database metadata
Whether the field type typically needs quotes
Properly formatted default value for SQL
Protected generateGenerates all inline Table Value Functions for an entity's recursive foreign keys Returns empty string if no recursive FKs exist
This function will handle the process of creating all of the generated objects like base view, stored procedures, etc. for all entities in the entities array. It will generate the SQL for each entity and then execute it.
Optional batchOptional enableSQLLoggingOptional enableSQLLoggingProtected generateProtected generateProtected generateDeprecated - do not use
Protected generateGenerates the SQL for creating indexes for the foreign keys in the entity
Protected generateUse generateRootIDJoins instead - kept for backward compatibility during migration Generates LEFT OUTER JOINs to the recursive CTEs
Protected generateGenerates the SELECT clause additions for root fields from TVFs Example: , root_ParentID.RootID AS [RootParentID]
Protected generateGenerates an inline Table Value Function for calculating root ID for a recursive FK field The function takes both the record ID and parent ID for optimization Returns SQL to create the function including DROP IF EXISTS
Protected generateGenerates OUTER APPLY joins to inline Table Value Functions for root ID calculation Each recursive FK gets an OUTER APPLY that calls its corresponding function
Protected generateSPCreateProtected generateSPDeleteProtected generateSPPermissionsProtected generateSPUpdateProtected generateOptional enableSQLLoggingProtected generateProtected generateProtected getIdentifies entities that need their delete stored procedures regenerated due to cascade dependencies on entities that had schema changes.
Protected getProtected getGets entities that had schema changes from the ManageMetadataBase tracking. Returns a map of entity names to their IDs for entities that had update-affecting changes.
Protected logSQLForProtected markMarks entities for delete stored procedure regeneration based on cascade dependencies. This should be called after metadata management and before SQL generation.
Protected orderOrders entities by their cascade delete dependencies using topological sort. Ensures that if Entity A's delete SP calls Entity B's update/delete SP, then Entity B is regenerated before Entity A.
All entities for name lookup
Set of entity IDs that need ordering
Array of entity IDs in dependency order
Protected stripID
This class is responsible for generating database level objects like views, stored procedures, permissions, etc. You can sub-class this class to create your own SQL generation logic or implement support for other databases. The base class implements support for SQL Server. In future versions of MJ, we will break out an abstract base class that has the skeleton of the logic and then the SQL Server version will be a sub-class of that abstract base class and other databases will be sub-classes of the abstract base class as well.