Skip to content

Commit

Permalink
Merge pull request #456 from imdrasil/task/conditionaly-disable-strin…
Browse files Browse the repository at this point in the history
…g-query-warning

Disable string query warning for postgres materialized view
  • Loading branch information
imdrasil authored Apr 3, 2024
2 parents 343d9c0 + 2ca8875 commit 0f4e4bd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ Jennifer::Config.from_uri(db)
* `"reverse_direction"` - invokes an opposite method to migration direction (`#down` for an up-migration)
* `"callback"` - invokes `#after_up_failure` on a failed up-migration and `#after_down_failure` on a failed down-migration
* `migration_files_path` - path to the location with migration files; default: `"./db/migrations"`
* `verbose_migrations` - outputs basic invoked migration information if set to `true`; default: `true`
* `model_files_path` - path to the models locations; is used by model and migration generators; default: `"./src/models"`
* `verbose_migrations` - outputs basic information about invoked migrations; default: `true`
* `model_files_path` - path to the models location; is used by model and migration generators; default: `"./src/models"`
* `structure_folder` - path to the database structure file location; if set to empty string - parent folder of `migration_files_path` is used; default: `""`
* `max_bind_vars_count` - maximum allowed count of bind variables; if nothing specified - used adapter's default value; default: `nil`
* `time_zone_aware_attributes` - whether Jennifer should convert time objects to UTC and back to application time zone when store/load them from a database; default: `true`
Expand Down
15 changes: 14 additions & 1 deletion docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ Jennifer::Config.configure do |conf|
conf.from_uri(ENV["DATABASE_URI"]) if ENV.has_key?("DATABASE_URI")
end
if APP_ENV == "development"
case APP_ENV
when "development"
Log.setup "db", :debug, Log::IOBackend.new(formatter: Jennifer::Adapter::DBColorizedFormatter)
when "test"
Log.setup "db", :none, Log::IOBackend.new
else
Log.setup "db", :error, Log::IOBackend.new(formatter: Jennifer::Adapter::DBFormatter)
end
Expand Down Expand Up @@ -217,3 +220,13 @@ require "../db/migrations/*" # you need to load all your migrations
Jennifer::Migration::Runner.migrate
```

To suppress all logs:

```crystal
Log.setup "db", :none, Log::IOBackend.new
Jennifer::Config.configure do |conf|
conf.verbose_migrations = false
end
```
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ module Jennifer

private def generate_query
if @query.is_a?(String)
puts "String was used for describing source request of materialized view. Use QueryBuilder::Query instead"
if Config.config.verbose_migrations
puts "WARNING: string was used for describing source request of materialized view. " \
"Use QueryBuilder::Query instead"
end
@query.as(String)
else
String.build do |io|
Expand Down

0 comments on commit 0f4e4bd

Please sign in to comment.