- Upgrade to .NET8
- Make project AOT ready and prepare and test AOT builds.
Generated unit tests project will now use XUnit.Npgsql library.
Now, dir names can accept named formats (instead of just numbers). This applies to DbObjectsDir
˙and all DbObjectsDirNames
(Tables
, Views
, Enums
, Sequences
, Functions
, Procedures
, Extensions
).
Available named formats are:
- "0" - constructed file name:
subdir/schema_name_object_name.sql
where subdir is schema name if not public, otherwise it's empty (base dir). This is for compatibility with previous versions. - "file" - same.
- "fileName" - same.
- "1" - schema name.
- "schema" - same.
- "2" - object name.
- "name" - same.
- "3" - connection name
- "connection" - same.
- "4" - object count number (for this type).
- "count" - same.
- "number" - same.
This feature is added to support flyway migrations name format for repeatable migrations.
For example, if we have DbObjectsDirNames
set to {"Functions": "R__F_{count}_{schema}.{name}.sql"}
then we will have following directory files:
/R__F_1_public.func1.sql
/R__F_1_public.func2.sql
This repeatable flyway migration format.
Default name settings are the same as before.
```json
## 5.3.5
- Massive improvements to markdown documentation generation.
- New settings `MdIncludeRoutineDefinitions` - should it include routine definitions in markdown documentation. Default is false.
## 5.3.4
* Upgrade Nuggets
- Sanitize anonymous script name for markdown update script
- Fix issue with exporting documentation file to HTML.
- Fix: when generating code summary comments, replace all
%
with&
to avoid problems with XML comments. - Fix: fix code generation for procedures.
- Fix: trim routine definition comments and remove all empty lines
- Fix: include routine definition comments for routines not created with string constants. (e.g. "create function test() returns text return 'hello world'"), including "BEGIN ATOMIC" style of routine.
- New: Setting
RoutinesOpenConnectionIfClosed
(default is true). Set to false to skip opening the connection (if closed) in every routine.
- Fix: when generating code summary comments, replace all
<
with<
and>
with>
to avoid problems with XML comments.
- New settings
RoutinesIncludeDefintionInComment
(default false) - this setting, if set to true will include routine definition in summary comment in generated code surrounded by<code>
tags.
This creates a nice effect when using Visual Studio intellisense autocomplete where we can see the entire routine in the tooltip nicely formatted.
- Settings
RoutinesCustomDirs
renamed toCustomDirs
and now it applies also to DB objects (tables, views, enums, etc.) and not only to routines.
- Fix: fix extension link when using RoutinesCustomDirs in markdown output.
- Fix: fix a bug caused by the last fix (primary keys in markdown document).
- Fix: fix repeated column names (PK and FK) in markdown document.
- Fix: in markdown document, when showing table output from function, write "RECORD" when function output is a single record.
This is dictionary settings where key is "similar to" expression that matches routine names and value is directory name. When routine name matches key, then directory name is used as directory for routine output. This is useful when you have many routines and you want to split them into multiple directories.
For example, if we have these settings:
"OutputDir": "./Test/Extensions/{0}/",
"RoutinesCustomDirs": {
"%upload%": "Upload/Dir1"
},
Routine with following names will be created in following directories with following names:
public.test1
->./Test/Extensions/Test1.cs
(namespaceTest.Extensions
)my_schema.test2
->./Test/Extensions/MySchema/Test1.cs
(namespaceTest.Extensions.MySchema
)public.test_upload
->./Test/Extensions/Upload/Dir1/TestUpload.cs
(namespaceTest.Extensions.Upload.Dir1
) - matches"%upload%": "Upload/Dir1"
my_schema.test_upload
->./Test/Extensions/MySchema/Upload/Dir1/TestUpload.cs
(namespaceTest.Extensions.MySchema.Upload.Dir1
) - matches"%upload%": "Upload/Dir1"
- Fix: fix problem with nullable models
- Fix: fix method generation when returning a single record.
- Fix: include
"#pragma warning disable CS8618"
suppression in generated code, defaultSourceHeaderLines
option. Necessary for generation NON NULLABLE model fields. - Fix: when returning USER-DEFINED type (a table), include all fields from that table in a routine query.
- Fix: when returning USER-DEFINED type (a table), set custom model as nullable type to avoid warnings.
- Fix: better error messages for custom mappings errors with suggestion to add mapping in configuration.
- Fix: enum types models generation
- Fix: When creating inserts list from a query, parse column names properly first.
- Fix: Settings
SchemaDumpNoTransaction
andDataDumpNoTransaction
set to default true.
- Fix: Fix update returning shortcut
- Fix: Fix search bug when searching trough functions.
-
Fix: Fixed bug with console parameters when working without configuration.
-
Fix: returned missing settings command to show all current settings.
*Fix: Fix issue with proc.proretset
-
New: Having a
cspoj
project file is no longer necessary when generating a C# code. Default name-space will be assumed from current directory name. -
New: Creation of configuration file is possible even when connection could not be established.
-
New: More details on error connection.
-
New: Creation of configuration file on command
--write-config-file [file name]
or--wcf [file name]
(only when it was not created automatically) -
New: Removed entire
diff
section from the configuration file. "Diff" is still possible, but only from command line. It will remain hidden until throughly tested and stabilized. -
Fix: Improved configuration file help comments very much.
-
Fix: model outputs from
ModelOutputQuery
doesn't have to contain any data for model to be generated. -
Fix:
ModelOutputQuery
renamedModelOutput
(and shortcutsmoq
and-mo
or-model
) and now contains a table or view name instead of a query. -
New: Added enums support to model generation.
-
New: Added
ModelSaveToModelDir
(command line-mos
,--model-save-to-model-dir
,--mos
,--model-save
,-model-save
) that will save each model or enum in specific file in the model directory set byModelDir
setting. -
New: Added
ConfigFile
setting (-cf --cf -config --config -config-file --config-file) to load custom configuration file. -
New: Returned functional
--help
. -
Fix: Fix bug not displaying routines on Definition command.
-
Fix: Fix proper showing of user defined routine parameters on list command.
-
Fix: bug on markdown creation on views returning enum field type.
-
Fix: disable mutually exclusive settings.
-
New: List setting (
-l -ls --ls --list
) is converted from bool to string. If parameter value is not included it acts like a switch. If parameter value is included it will be used as a filter for list command. Search matches are highlighted. -
New: Definition setting (
-def -ddl --ddl -definition --definition
) now can use*
to dump all object definitions. -
New: Search setting (
-s --s --search
) will search and highlight all matching objects definitions that definition contains searched string. -
New: Info setting (
--info
) includes lot more information like exe dir, OS, pg_dump and pg_restore versions. Also, connection info includes server version. -
Fix: error trying to enumerate directory with invalid characters on execute command.
-
Fix: fix routine data access code-gen when returning single complex type or set of complex types.
From version 5, pgroutiner
can generate CRUD routines for your database tables.
Example of generated CRUD routine (create on conflict do update) for the test_table
table to console (-console
switch):
$ pgroutiner -console -create-on-conflict-do-update-returning test_table
drop function if exists "test_table_create_on_conflict_do_update_returning"(int2, varchar, int2[], numeric);
--
-- function "test_table_create_on_conflict_do_update_returning"(int2, varchar, int2[], numeric)
--
create function "test_table_create_on_conflict_do_update_returning"(
_id int2,
_name varchar,
_types int2[],
_height_cm numeric
)
returns "test_table"
language sql
volatile
as $$
insert into "test_table"
(
"id",
"name",
"types",
"height_cm"
)
overriding system value values
(
_id,
_name,
_types,
_height_cm
)
on conflict ("id") do update set
"name" = EXCLUDED."name",
"types" = EXCLUDED."types",
"height_cm" = EXCLUDED."height_cm"
returning
"id",
"name",
"default",
"default_name",
"types",
"height_cm",
"height_in",
"created_at";
$$;
comment on function "test_table_create_on_conflict_do_update_returning"(int2, varchar, int2[], numeric) is 'Create and return a new record in table "test_table" and update a row with new data on key violation (id).';
$
New settings:
- Type: string
- Default value: null (not used)
Applies additional attributes to generated CRUD functions. For example, if you want to add security definer
attribute to all generated CRUD functions, you can set this setting to security definer
.
- Type: boolean
- Default value: false
If set to true, generated CRUD functions will use coalesce
function to set default values for columns that have default values defined in database.
This applies only to insert
and update
CRUD functions. When used, parameters that create or update default values will be included and will fallback to default when set to NULL.
For example: coalesce(_parameter_with_default_value, 'default value eyxpression'::character varying),
- Type: string
- Default value:
{0}\"{1}_{2}\"
Sets the pattern for generated CRUD function names using format placeholders:
{0}
is replaced with schema name. If schema is public it is skipped, otherwise quoted schema name.{1}
is replaced with table name (unquoted).{2}
is replaced with applied CRUD setting suffix in lower underline case. For example, if settingCrudCreateOnConflictDoNothingReturning
is used, this will becreate_on_conflict_do_nothing_returning
.
- Type: string
- Default value: null (not used)
Similar to expression of table names to generate function for this CRUD type.
Setting CrudCreateReturning
(override commands -create_returning
, -create-returning
, --crud-create-returning
)
- Type: string
- Default value: null (not used)
Similar to expression of table names to generate function for this CRUD type.
Setting CrudCreateOnConflictDoNothing
(override commands -create_on_conflict_do_nothing
, -create-on-conflict-do-nothing
, --crud-create-on-conflict-do-nothing
)
- Type: string
- Default value: null (not used)
Similar to expression of table names to generate function for this CRUD type.
Setting CrudCreateOnConflictDoNothingReturning
(override commands -create_on_conflict_do_nothing_returning
, -create-on-conflict-do-nothing-returning
, --crud-create-on-conflict-do-nothing-returning
)
- Type: string
- Default value: null (not used)
Similar to expression of table names to generate function for this CRUD type.
Setting CrudCreateOnConflictDoUpdate
(override commands -create_on_conflict_do_update
, -create-on-conflict-do-update
, --crud-create-on-conflict-do-update
)
- Type: string
- Default value: null (not used)
Similar to expression of table names to generate function for this CRUD type.
Setting CrudCreateOnConflictDoUpdateReturning
(override commands -create_on_conflict_do_update_returning
, -create-on-conflict-do-update-returning
, --crud-create-on-conflict-do-update-returning
)
- Type: string
- Default value: null (not used)
Similar to expression of table names to generate function for this CRUD type.
- Type: string
- Default value: null (not used)
Similar to expression of table names to generate function for this CRUD type.
- Type: string
- Default value: null (not used)
Similar to expression of table names to generate function for this CRUD type.
- Type: string
- Default value: null (not used)
Similar to expression of table names to generate function for this CRUD type.
- Type: string
- Default value: null (not used)
Similar to expression of table names to generate function for this CRUD type.
Setting CrudUpdateReturning
(override commands -crud_update_returning
, -crud-update-returning
, --crud-update-returning
)
- Type: string
- Default value: null (not used)
Similar to expression of table names to generate function for this CRUD type.
- Type: string
- Default value: null (not used)
Similar to expression of table names to generate function for this CRUD type.
Setting CrudDeleteByReturning
(override commands -delete_by_returning
, -delete-by-returning
, --crud-delete-by-returning
)
- Type: string
- Default value: null (not used)
Similar to expression of table names to generate function for this CRUD type.