Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump sequel from 5.84.0 to 5.85.0 #679

Merged
merged 1 commit into from
Oct 24, 2024
Merged

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Oct 21, 2024

Bumps sequel from 5.84.0 to 5.85.0.

Changelog

Sourced from sequel's changelog.

=== 5.85.0 (2025-10-01)

  • Support json_table on PostgreSQL 17+ in the pg_json_ops extension (jeremyevans)

  • Make Dataset#get and #first without argument not create intermediate datasets if receiver uses raw SQL (jeremyevans)

  • Add dataset_run extension, for building SQL using datasets, and running with Database#run (jeremyevans)

  • Switch default connection pool to timed_queue on Ruby 3.2+ (jeremyevans)

Commits
  • b982668 Bump version to 5.85.0
  • 7a15c83 Fix example json_table code in pg_json_ops extension
  • a21966c Adjust PostgreSQL 17 spec for PostgreSQL 17.0
  • fe1bc3f Support json_table on PostgreSQL 17+ in the pg_json_ops extension
  • e38045c Update temporarily_release_connection spec now that default connection pool t...
  • 0f4cce2 Update Custom SQL section of querying guide
  • 45b7f37 Make Dataset#get and #first without argument not create intermediate datasets...
  • 26a2243 Add dataset_run extension, for building SQL using datasets, and running with ...
  • 8268b44 Switch default connection pool to timed_queue on Ruby 3.2+
  • See full diff in compare view

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Bumps [sequel](https://github.com/jeremyevans/sequel) from 5.84.0 to 5.85.0.
- [Changelog](https://github.com/jeremyevans/sequel/blob/master/CHANGELOG)
- [Commits](jeremyevans/sequel@5.84.0...5.85.0)

---
updated-dependencies:
- dependency-name: sequel
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
@dependabot dependabot bot added dependencies ruby Pull requests that update Ruby code labels Oct 21, 2024
Copy link

Copy link

gem compare sequel 5.84.0 5.85.0

Compared versions: ["5.84.0", "5.85.0"]
  DIFFERENT date:
    5.84.0: 2024-09-01 00:00:00 UTC
    5.85.0: 2024-10-01 00:00:00 UTC
  DIFFERENT rubygems_version:
    5.84.0: 3.5.11
    5.85.0: 3.5.16
  DIFFERENT version:
    5.84.0: 5.84.0
    5.85.0: 5.85.0
  DIFFERENT files:
    5.84.0->5.85.0:
      * Added:
            lib/sequel/extensions/dataset_run.rb +41/-0
      * Changed:
            lib/sequel/connection_pool.rb +2/-2
            lib/sequel/dataset/actions.rb +9/-1
            lib/sequel/extensions/pg_json_ops.rb +314/-8
            lib/sequel/version.rb +1/-1

Copy link

gem compare --diff sequel 5.84.0 5.85.0

Compared versions: ["5.84.0", "5.85.0"]
  DIFFERENT files:
    5.84.0->5.85.0:
      * Added:
        lib/sequel/extensions/dataset_run.rb
                --- /tmp/20241021-2093-3e08b8	2024-10-21 02:01:38.658030079 +0000
                +++ /tmp/d20241021-2093-gtd9gx/sequel-5.85.0/lib/sequel/extensions/dataset_run.rb	2024-10-21 02:01:38.626029941 +0000
                @@ -0,0 +1,41 @@
                +# frozen-string-literal: true
                +#
                +# The dataset_run extension is designed for cases where you want
                +# to use dataset methods to build a query, but want to run that
                +# query without returning a result.  The most common need would
                +# be to easily use placeholders in an SQL string, which Database#run
                +# does not support directly.
                +#
                +# You can load this extension into specific datasets:
                +#
                +#   ds = DB["GRANT SELECT ON ? TO ?", :table, :user]
                +#   ds = ds.extension(:dataset_run)
                +#   ds.run
                +#
                +# Or you can load it into all of a database's datasets, which
                +# is probably the desired behavior if you are using this extension:
                +#
                +#   DB.extension(:dataset_run)
                +#   DB["GRANT SELECT ON ? TO ?", :table, :user].run
                +#
                +# Related module: Sequel::DatasetRun
                +
                +#
                +module Sequel
                +  module DatasetRun
                +    # Run the dataset's SQL on the database.  Returns NULL.  This is
                +    # useful when you want to run SQL without returning a result.
                +    #
                +    #   DB["GRANT SELECT ON ? TO ?", :table, :user].run
                +    #   # GRANT SELECT ON "table" TO "user"
                +    def run
                +      if server = @opts[:server]
                +        db.run(sql, :server=>server)
                +      else
                +        db.run(sql)
                +      end
                +    end
                +  end
                +
                +  Dataset.register_extension(:dataset_run, DatasetRun)
                +end
      * Changed:
        lib/sequel/connection_pool.rb
                --- /tmp/d20241021-2093-gtd9gx/sequel-5.84.0/lib/sequel/connection_pool.rb	2024-10-21 02:01:38.514029459 +0000
                +++ /tmp/d20241021-2093-gtd9gx/sequel-5.85.0/lib/sequel/connection_pool.rb	2024-10-21 02:01:38.618029907 +0000
                @@ -73,2 +73 @@
                -        # :nocov:
                -        elsif RUBY_VERSION >= '3.4' # SEQUEL6 or maybe earlier switch to 3.2
                +        elsif RUBY_VERSION >= '3.2'
                @@ -79,0 +79 @@
                +        # :nocov:
        lib/sequel/dataset/actions.rb
                --- /tmp/d20241021-2093-gtd9gx/sequel-5.84.0/lib/sequel/dataset/actions.rb	2024-10-21 02:01:38.518029476 +0000
                +++ /tmp/d20241021-2093-gtd9gx/sequel-5.85.0/lib/sequel/dataset/actions.rb	2024-10-21 02:01:38.622029924 +0000
                @@ -220 +220 @@
                -          return single_record
                +          return(@opts[:sql] ? single_record! : single_record)
                @@ -284,0 +285,6 @@
                +    #
                +    # If called on a dataset with raw SQL, returns the
                +    # first value in the dataset without changing the selection or setting a limit:
                +    #
                +    #   DB["SELECT id FROM table"].get # SELECT id FROM table
                +    #   # =>  3
                @@ -291,0 +298,2 @@
                +      elsif no_arg && opts[:sql]
                +        return ds.single_value!
        lib/sequel/extensions/pg_json_ops.rb
                --- /tmp/d20241021-2093-gtd9gx/sequel-5.84.0/lib/sequel/extensions/pg_json_ops.rb	2024-10-21 02:01:38.530029527 +0000
                +++ /tmp/d20241021-2093-gtd9gx/sequel-5.85.0/lib/sequel/extensions/pg_json_ops.rb	2024-10-21 02:01:38.634029975 +0000
                @@ -90,0 +91,6 @@
                +# For the PostgreSQL 12+ SQL/JSON path functions, one argument is required (+path+) and
                +# two more arguments are optional (+vars+ and +silent+).  +path+ specifies the JSON path.
                +# +vars+ specifies a hash or a string in JSON format of named variables to be
                +# substituted in +path+. +silent+ specifies whether errors are suppressed. By default,
                +# errors are not suppressed.
                +#
                @@ -99,6 +104,0 @@
                -# For the PostgreSQL 12+ SQL/JSON path functions, one argument is required (+path+) and
                -# two more arguments are optional (+vars+ and +silent+).  +path+ specifies the JSON path.
                -# +vars+ specifies a hash or a string in JSON format of named variables to be
                -# substituted in +path+. +silent+ specifies whether errors are suppressed. By default,
                -# errors are not suppressed.
                -#
                @@ -132,2 +132,2 @@
                -#   j.is_not_json(type: :array)                # j IS NOT JSON ARRAY
                -#   j.is_not_json(unique: true)                # j IS NOT JSON WITH UNIQUE
                +#   j.is_not_json(type: :array)            # j IS NOT JSON ARRAY
                +#   j.is_not_json(unique: true)            # j IS NOT JSON WITH UNIQUE
                @@ -145,0 +146,23 @@
                +#   j.table('$.foo') do
                +#      String :bar
                +#      Integer :baz
                +#   end
                +#   # json_table("jsonb_column", '$.foo' COLUMNS("bar" text, "baz" integer))
                +#
                +#   j.table('$.foo', passing: {a: 1}) do
                +#      ordinality :id
                +#      String :bar, format: :json, on_error: :empty_object
                +#      nested '$.baz' do
                +#        Integer :q, path: '$.quux', on_empty: :error
                +#      end
                +#      exists :x, Date, on_error: false
                +#   end
                +#   # json_table(jsonb_column, '$.foo' PASSING 1 AS a COLUMNS(
                +#   #   "id" FOR ORDINALITY,
                +#   #   "bar" text FORMAT JSON EMPTY OBJECT ON ERROR,
                +#   #   NESTED '$.baz' COLUMNS(
                +#   #     "q" integer PATH '$.quux' ERROR ON EMPTY
                +#   #   ),
                +#   #   "d" date EXISTS FALSE ON ERROR
                +#   # ))
                +#
                @@ -366,0 +390,66 @@
                +      # Returns json_table SQL function expression, querying JSON data and returning
                +      # the results as a relational view, which can be accessed similarly to a regular
                +      # SQL table. This accepts a block that is handled in a similar manner to
                +      # Database#create_table, though it operates differently.
                +      #
                +      # Table level options:
                +      #
                +      # :on_error :: How to handle errors when evaluating the JSON path expression.
                +      #              :empty_array :: Return an empty array/result set
                +      #              :error :: raise a DatabaseError
                +      # :passing :: Variables to pass to the JSON path expression.  Keys are variable
                +      #             names, values are the values of the variable.
                +      #
                +      # Inside the block, the following methods can be used:
                +      #
                +      # ordinality(name) :: Include a FOR ORDINALITY column, which operates similar to an
                +      #                     autoincrementing primary key.
                +      # column(name, type, opts={}) :: Return a normal column that uses the given type.
                +      # exists(name, type, opts={}) :: Return a boolean column for whether the JSON path yields any values.
                +      # nested(path, &block) :: Extract nested data from the result set at the given path.
                +      #                         This block is treated the same as a json_table block, and
                +      #                         arbitrary levels of nesting are supported.
                +      # 
                +      # The +column+ method supports the following options:
                +      # 
                +      # :path :: JSON path to the object (the default is <tt>$.NAME</tt>, where +NAME+ is the
                +      #          name of the column).
                +      # :format :: Set to +:json+ to use FORMAT JSON, when you expect the value to be a
                +      #            valid JSON object.
                +      # :on_empty, :on_error :: How to handle case where JSON path evaluation is empty or
                +      #                         results in an error. Values supported are:
                +      #                         :empty_array :: Return empty array (requires <tt>format: :json</tt>)
                +      #                         :empty_object :: Return empty object (requires <tt>format: :json</tt>)
                +      #                         :error :: Raise a DatabaseError
                +      #                         :null :: Return nil (NULL)
                +      # :wrapper :: How to wrap returned values:
                +      #             true, :unconditional :: Always wrap returning values in an array
                +      #             :conditional :: Only wrap multiple return values in an array
                +      #             :keep_quotes :: Wrap scalar strings in quotes
                +      #             :omit_quotes :: Do not wrap scalar strings in quotes
                +      #
                +      # The +exists+ method supports the following options:
                +      #
                +      # :path :: JSON path to the object (same as +column+ option)
                +      # :on_error :: How to handle case where JSON path evaluation results in an error.
                +      #              Values supported are:
                +      #              :error :: Raise a DatabaseError
                +      #              true :: Return true
                +      #              false :: Return false
                +      #              :null :: Return nil (NULL)
                +      #
                +      # Inside the block, methods for Ruby class names are also supported, allowing you
                +      # to use syntax such as:
                +      #
                +      #   json_op.table('$.a') do
                +      #     String :b
                +      #     Integer :c, path: '$.d'
                +      #   end
                +      #
                +      # One difference between this method and Database#create_table is that method_missing
                +      # is not supported inside the block.  Use the +column+ method for PostgreSQL types
                +      # that are not mapped to Ruby classes.
                +      def table(path, opts=OPTS, &block)
                +        JSONTableOp.new(self, path, opts, &block)
                +      end
                +
                @@ -1031,0 +1121,217 @@
                +      end
                +    end
                +
                +    # Object representing json_table calls
                +    class JSONTableOp < SQL::Expression
                +      TABLE_ON_ERROR_SQL = {
                +        :error => ' ERROR ON ERROR',
                +        :empty_array => ' EMPTY ARRAY ON ERROR',
                +      }.freeze
                +      private_constant :TABLE_ON_ERROR_SQL
                +
                +      COLUMN_ON_SQL = {
                +        :null =>  ' NULL',
                +        :error => ' ERROR',
                +        :empty_array => ' EMPTY ARRAY',
                +        :empty_object => ' EMPTY OBJECT',
                +      }.freeze
                +      private_constant :COLUMN_ON_SQL
                +
                +      EXISTS_ON_ERROR_SQL = {
                +        :error => ' ERROR',
                +        true => ' TRUE',
                +        false => ' FALSE',
                +        :null => ' UNKNOWN',
                +      }.freeze
                +      private_constant :EXISTS_ON_ERROR_SQL
                +
                +      WRAPPER = {
                +        :conditional => ' WITH CONDITIONAL WRAPPER',
                +        :unconditional => ' WITH WRAPPER',
                +        :omit_quotes => ' OMIT QUOTES',
                +        :keep_quotes => ' KEEP QUOTES',
                +      }
                +      WRAPPER[true] = WRAPPER[:unconditional]
                +      WRAPPER.freeze
                +      private_constant :WRAPPER
                +
                +      # Class used to evaluate json_table blocks and nested blocks
                +      class ColumnDSL
                +        # Return array of column information recorded for the instance
                +        attr_reader :columns
                +
                +        def self.columns(&block)
                +          new(&block).columns.freeze
                +        end
                +
                +        def initialize(&block)
                +          @columns = []
                +          instance_exec(&block)
                +        end
                +
                +        # Include a FOR ORDINALITY column
                +        def ordinality(name)
                +          @columns << [:ordinality, name].freeze
                +        end
                +
                +        # Include a regular column with the given type
                +        def column(name, type, opts=OPTS)
                +          @columns << [:column, name, type, opts].freeze
                +        end
                +
                +        # Include an EXISTS column with the given type
                +        def exists(name, type, opts=OPTS)
                +          @columns << [:exists, name, type, opts].freeze
                +        end
                +
                +        # Include a nested set of columns at the given path.
                +        def nested(path, &block)
                +          @columns << [:nested, path, ColumnDSL.columns(&block)].freeze
                +        end
                +
                +        # Include a bigint column
                +        def Bignum(name, opts=OPTS)
                +          @columns << [:column, name, :Bignum, opts].freeze
                +        end
                +
                +        # Define methods for handling other generic types
                +        %w'String Integer Float Numeric BigDecimal Date DateTime Time File TrueClass FalseClass'.each do |meth|
                +          klass = Object.const_get(meth)
                +          define_method(meth) do |name, opts=OPTS|
                +            @columns << [:column, name, klass, opts].freeze
                +          end
                +        end
                +      end
                +      private_constant :ColumnDSL
                +
                +      # See JSONBaseOp#table for documentation on the options.
                +      def initialize(expr, path, opts=OPTS, &block)
                +        @expr = expr
                +        @path = path
                +        @passing = opts[:passing]
                +        @on_error = opts[:on_error]
                +        @columns = opts[:_columns] || ColumnDSL.columns(&block)
                +        freeze
                +      end
                +
                +      # Append the json_table function call expression to the SQL
                +      def to_s_append(ds, sql)
                +        sql << 'json_table('
                +        ds.literal_append(sql, @expr)
                +        sql << ', '
                +        default_literal_append(ds, sql, @path)
                +
                +        if (passing = @passing) && !passing.empty?
                +          sql << ' PASSING '
                +          comma = false
                +          passing.each do |k, v|
                +            if comma
                +              sql << ', '
                +            else
                +              comma = true
                +            end
                +            ds.literal_append(sql, v)
                +            sql << " AS " << k.to_s
                +          end
                +        end
                +
                +        to_s_append_columns(ds, sql, @columns)
                +        sql << TABLE_ON_ERROR_SQL.fetch(@on_error) if @on_error
                +        sql << ')'
                +      end
                +
                +      # Support transforming of json_table expression
                +      def sequel_ast_transform(transformer)
                +        opts = {:on_error=>@on_error, :_columns=>@columns}
                +
                +        if @passing
                +          passing = opts[:passing] = {}
                +          @passing.each do |k, v|
                +            passing[k] = transformer.call(v)
                +          end
                +        end
                +
                +        self.class.new(transformer.call(@expr), @path, opts)
                +      end
                +
                +      private
                +
                +      # Append the set of column information to the SQL.  Separated to handle
                +      # nested sets of columns.
                +      def to_s_append_columns(ds, sql, columns)
                +        sql << ' COLUMNS('
                +        comma = nil
                +        columns.each do |column|
                +          if comma
                +            sql << comma
                +          else
                +            comma = ', '
                +          end
                +          to_s_append_column(ds, sql, column)
                +        end
                +        sql << ')'
                +      end
                +
                +      # Append the column information to the SQL.  Handles the various
                +      # types of json_table columns.
                +      def to_s_append_column(ds, sql, column)
                +        case column[0]
                +        when :column
                +          _, name, type, opts = column
                +          ds.literal_append(sql, name)
                +          sql << ' ' << ds.db.send(:type_literal, opts.merge(:type=>type)).to_s
                +          sql << ' FORMAT JSON' if opts[:format] == :json
                +          to_s_append_path(ds, sql, opts[:path])
                +          sql << WRAPPER.fetch(opts[:wrapper]) if opts[:wrapper]
                +          to_s_append_on_value(ds, sql, opts[:on_empty], " ON EMPTY")
                +          to_s_append_on_value(ds, sql, opts[:on_error], " ON ERROR")
                +        when :ordinality
                +          ds.literal_append(sql, column[1])
                +          sql << ' FOR ORDINALITY'
                +        when :exists
                +          _, name, type, opts = column
                +          ds.literal_append(sql, name)
                +          sql << ' ' << ds.db.send(:type_literal, opts.merge(:type=>type)).to_s
                +          sql << ' EXISTS'
                +          to_s_append_path(ds, sql, opts[:path])
                +          unless (on_error = opts[:on_error]).nil?
                +            sql << EXISTS_ON_ERROR_SQL.fetch(on_error) << " ON ERROR"
                +          end
                +        else # when :nested
                +          _, path, columns = column
                +          sql << 'NESTED '
                +          default_literal_append(ds, sql, path)
                +          to_s_append_columns(ds, sql, columns)
                +        end
                +      end
                +
                +      # Handle DEFAULT values in ON EMPTY/ON ERROR fragments
                +      def to_s_append_on_value(ds, sql, value, cond)
                +        if value
                +          if v = COLUMN_ON_SQL[value]
                +            sql << v
                +          else
                +            sql << ' DEFAULT '
                +            default_literal_append(ds, sql, value)
                +          end
                +          sql << cond
                +        end
                +      end
                +
                +      # Append path caluse to the SQL
                +      def to_s_append_path(ds, sql, path)
                +        if path
                +          sql << ' PATH '
                +          default_literal_append(ds, sql, path)
                +        end
                +      end
                +
                +      # Do not auto paramterize default value or path value, as PostgreSQL doesn't allow it.
                +      def default_literal_append(ds, sql, v)
                +        if sql.respond_to?(:skip_auto_param)
                +          sql.skip_auto_param do
                +            ds.literal_append(sql, v)
                +          end
                +        else
                +          ds.literal_append(sql, v)
                +        end
        lib/sequel/version.rb
                --- /tmp/d20241021-2093-gtd9gx/sequel-5.84.0/lib/sequel/version.rb	2024-10-21 02:01:38.554029631 +0000
                +++ /tmp/d20241021-2093-gtd9gx/sequel-5.85.0/lib/sequel/version.rb	2024-10-21 02:01:38.658030079 +0000
                @@ -9 +9 @@
                -  MINOR = 84
                +  MINOR = 85

@dentarg dentarg merged commit 3e1a6a6 into main Oct 24, 2024
12 checks passed
@dentarg dentarg deleted the dependabot/bundler/sequel-5.85.0 branch October 24, 2024 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies ruby Pull requests that update Ruby code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant