{"repository_name":"github.com/crystal-lang/crystal-db","body":"[![Build Status](https://travis-ci.org/crystal-lang/crystal-db.svg?branch=master)](https://travis-ci.org/crystal-lang/crystal-db)\n\n# crystal-db\n\nCommon db api for crystal. You will need to a specific driver to access a database.\n\n* [sqlite](https://github.com/crystal-lang/crystal-sqlite3)\n* [mysql](https://github.com/crystal-lang/crystal-mysql)\n* [postgres](https://github.com/will/crystal-pg)\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n db:\n github: crystal-lang/crystal-db\n```\n\n## Documentation\n\n* [Latest API](http://crystal-lang.github.io/crystal-db/api/latest/)\n* [Crystal book](https://crystal-lang.org/docs/database/)\n\n## Usage\n\nSince this is an abstract db api, it's usage is through a concrete database driver.\n\n```crystal\nrequire \"db\"\nrequire \"sqlite3\"\n\nDB.open \"sqlite3:./file.db\" do |db|\n # When using the pg driver, use $1, $2, etc. instead of ?\n db.exec \"create table contacts (name text, age integer)\"\n db.exec \"insert into contacts values (?, ?)\", \"John Doe\", 30\n\n args = [] of DB::Any\n args << \"Sarah\"\n args << 33\n db.exec \"insert into contacts values (?, ?)\", args\n\n puts \"max age:\"\n puts db.scalar \"select max(age) from contacts\" # => 33\n\n puts \"contacts:\"\n db.query \"select name, age from contacts order by age desc\" do |rs|\n puts \"#{rs.column_name(0)} (#{rs.column_name(1)})\"\n # => name (age)\n rs.each do\n puts \"#{rs.read(String)} (#{rs.read(Int32)})\"\n # => Sarah (33)\n # => John Doe (30)\n end\n end\nend\n```\n\n## Roadmap\n\nIssues not yet addressed\n\n- [x] Support non prepared statements. [#25](https://github.com/crystal-lang/crystal-db/pull/25)\n- [x] Time data type. (implementation details depends on actual drivers)\n- [x] Data type extensibility. Allow each driver to extend the data types allowed.\n- [x] Transactions & nested transactions. [#27](https://github.com/crystal-lang/crystal-db/pull/27)\n- [x] Connection pool.\n- [ ] Direct access to `IO` to avoid memory allocation for blobs.\n\n## Contributing\n\n1. Fork it ( https://github.com/crystal-lang/crystal-db/fork )\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Add some feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create a new Pull Request\n\n## Contributors\n\n- [bcardiff](https://github.com/bcardiff) Brian J. Cardiff - creator, maintainer\n","program":{"html_id":"github.com/crystal-lang/crystal-db/toplevel","path":"toplevel.html","kind":"module","full_name":"Top Level Namespace","name":"Top Level Namespace","abstract":false,"superclass":null,"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/Spec/Methods","kind":"module","full_name":"Spec::Methods","name":"Methods"},{"html_id":"github.com/crystal-lang/crystal-db/Spec/Expectations","kind":"module","full_name":"Spec::Expectations","name":"Expectations"}],"locations":[],"repository_name":"github.com/crystal-lang/crystal-db","program":true,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/crystal-lang/crystal-db/Spec/Expectations","kind":"module","full_name":"Spec::Expectations","name":"Expectations"},{"html_id":"github.com/crystal-lang/crystal-db/Spec/Methods","kind":"module","full_name":"Spec::Methods","name":"Methods"}],"extended_modules":[{"html_id":"github.com/crystal-lang/crystal-db/Spec/Expectations","kind":"module","full_name":"Spec::Expectations","name":"Expectations"},{"html_id":"github.com/crystal-lang/crystal-db/Spec/Methods","kind":"module","full_name":"Spec::Methods","name":"Methods"}],"subclasses":[],"including_types":[],"namespace":null,"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[{"html_id":"github.com/crystal-lang/crystal-db/DB","path":"DB.html","kind":"module","full_name":"DB","name":"DB","abstract":false,"superclass":null,"ancestors":[],"locations":[{"filename":"db.cr","line_number":68,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db.cr"},{"filename":"db/pool.cr","line_number":3,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr"},{"filename":"db/string_key_cache.cr","line_number":1,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/string_key_cache.cr"},{"filename":"db/query_methods.cr","line_number":1,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr"},{"filename":"db/session_methods.cr","line_number":1,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr"},{"filename":"db/disposable.cr","line_number":1,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/disposable.cr"},{"filename":"db/driver.cr","line_number":1,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/driver.cr"},{"filename":"db/statement.cr","line_number":1,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr"},{"filename":"db/begin_transaction.cr","line_number":1,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/begin_transaction.cr"},{"filename":"db/connection_context.cr","line_number":1,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/connection_context.cr"},{"filename":"db/connection.cr","line_number":1,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/connection.cr"},{"filename":"db/transaction.cr","line_number":1,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr"},{"filename":"db/pool_statement.cr","line_number":1,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_statement.cr"},{"filename":"db/database.cr","line_number":4,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/database.cr"},{"filename":"db/pool_prepared_statement.cr","line_number":1,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_prepared_statement.cr"},{"filename":"db/pool_unprepared_statement.cr","line_number":1,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_unprepared_statement.cr"},{"filename":"db/result_set.cr","line_number":1,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr"},{"filename":"db/error.cr","line_number":1,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/error.cr"},{"filename":"db/mapping.cr","line_number":1,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/mapping.cr"},{"filename":"spec.cr","line_number":9,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr"},{"filename":"db/version.cr","line_number":1,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/version.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[{"name":"TYPES","value":"[Nil, String, Bool, Int32, Int64, Float32, Float64, Time, Bytes]","doc":"Types supported to interface with database driver.\nThese can be used in any `ResultSet#read` or any `Database#query` related\nmethod to be used as query parameters","summary":"

Types supported to interface with database driver.

"},{"name":"VERSION","value":"\"0.4.4\"","doc":null,"summary":null}],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":null,"doc":"The DB module is a unified interface to database access.\nDatabase dialects is supported by custom database driver shards.\nCheck [crystal-lang/crystal-sqlite3](https://github.com/crystal-lang/crystal-sqlite3) for example.\n\nDrivers implementors check `Driver` class.\n\nDB manage a connection pool. The connection pool can be configured by `URI` query. See `Database`.\n\n### Usage\n\nAssuming `crystal-sqlite3` is included a sqlite3 database can be opened with `#open`.\n\n```\ndb = DB.open \"sqlite3:./path/to/db/file.db\"\ndb.close\n```\n\nIf a block is given to `#open` the database is closed automatically\n\n```\nDB.open \"sqlite3:./file.db\" do |db|\n # work with db\nend # db is closed\n```\n\nIn the code above `db` is a `Database`. Methods available for querying it are described in `QueryMethods`.\n\nThree kind of statements can be performed:\n1. `Database#exec` waits no response from the database.\n2. `Database#scalar` reads a single value of the response.\n3. `Database#query` returns a ResultSet that allows iteration over the rows in the response and column information.\n\nAll of the above methods allows parametrised query. Either positional or named arguments.\n\nCheck a full working version:\n\n```\nrequire \"db\"\nrequire \"sqlite3\"\n\nDB.open \"sqlite3:./file.db\" do |db|\n db.exec \"create table contacts (name text, age integer)\"\n db.exec \"insert into contacts values (?, ?)\", \"John Doe\", 30\n\n args = [] of DB::Any\n args << \"Sarah\"\n args << 33\n db.exec \"insert into contacts values (?, ?)\", args\n\n puts \"max age:\"\n puts db.scalar \"select max(age) from contacts\" # => 33\n\n puts \"contacts:\"\n db.query \"select name, age from contacts order by age desc\" do |rs|\n puts \"#{rs.column_name(0)} (#{rs.column_name(1)})\"\n # => name (age)\n rs.each do\n puts \"#{rs.read(String)} (#{rs.read(Int32)})\"\n # => Sarah (33)\n # => John Doe (30)\n end\n end\nend\n```\n","summary":"

The DB module is a unified interface to database access.

","class_methods":[{"id":"connect(uri:URI|String)-class-method","html_id":"connect(uri:URI|String)-class-method","name":"connect","doc":"Opens a connection using the specified *uri*.\nThe scheme of the *uri* determines the driver to use.\nReturned connection must be closed by `Connection#close`.\nIf a block is used the connection is yielded and closed automatically.","summary":"

Opens a connection using the specified uri.

","abstract":false,"args":[{"name":"uri","doc":null,"default_value":"","external_name":"uri","restriction":"URI | String"}],"args_string":"(uri : URI | String)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db.cr#L120","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db.cr#L120","def":{"name":"connect","args":[{"name":"uri","doc":null,"default_value":"","external_name":"uri","restriction":"URI | String"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"build_connection(uri)"}},{"id":"connect(uri:URI|String,&block)-class-method","html_id":"connect(uri:URI|String,&block)-class-method","name":"connect","doc":"Opens a connection using the specified *uri*.\nThe scheme of the *uri* determines the driver to use.\nReturned connection must be closed by `Connection#close`.\nIf a block is used the connection is yielded and closed automatically.","summary":"

Opens a connection using the specified uri.

","abstract":false,"args":[{"name":"uri","doc":null,"default_value":"","external_name":"uri","restriction":"URI | String"}],"args_string":"(uri : URI | String, &block)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db.cr#L125","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db.cr#L125","def":{"name":"connect","args":[{"name":"uri","doc":null,"default_value":"","external_name":"uri","restriction":"URI | String"}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"cnn = build_connection(uri)\nbegin\n yield cnn\nensure\n cnn.close\nend\n"}},{"id":"open(uri:URI|String)-class-method","html_id":"open(uri:URI|String)-class-method","name":"open","doc":"Opens a database using the specified *uri*.\nThe scheme of the *uri* determines the driver to use.\nReturned database must be closed by `Database#close`.\nIf a block is used the database is yielded and closed automatically.","summary":"

Opens a database using the specified uri.

","abstract":false,"args":[{"name":"uri","doc":null,"default_value":"","external_name":"uri","restriction":"URI | String"}],"args_string":"(uri : URI | String)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db.cr#L102","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db.cr#L102","def":{"name":"open","args":[{"name":"uri","doc":null,"default_value":"","external_name":"uri","restriction":"URI | String"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"build_database(uri)"}},{"id":"open(uri:URI|String,&block)-class-method","html_id":"open(uri:URI|String,&block)-class-method","name":"open","doc":"Same as `#open` but the database is yielded and closed automatically.","summary":"

Same as #open but the database is yielded and closed automatically.

","abstract":false,"args":[{"name":"uri","doc":null,"default_value":"","external_name":"uri","restriction":"URI | String"}],"args_string":"(uri : URI | String, &block)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db.cr#L107","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db.cr#L107","def":{"name":"open","args":[{"name":"uri","doc":null,"default_value":"","external_name":"uri","restriction":"URI | String"}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"db = build_database(uri)\nbegin\n yield db\nensure\n db.close\nend\n"}},{"id":"register_driver(driver_name,driver_class:Driver.class)-class-method","html_id":"register_driver(driver_name,driver_class:Driver.class)-class-method","name":"register_driver","doc":"Registers a driver class for a given *driver_name*.\nShould be called by drivers implementors only.","summary":"

Registers a driver class for a given driver_name.

","abstract":false,"args":[{"name":"driver_name","doc":null,"default_value":"","external_name":"driver_name","restriction":""},{"name":"driver_class","doc":null,"default_value":"","external_name":"driver_class","restriction":"Driver.class"}],"args_string":"(driver_name, driver_class : Driver.class)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db.cr#L90","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db.cr#L90","def":{"name":"register_driver","args":[{"name":"driver_name","doc":null,"default_value":"","external_name":"driver_name","restriction":""},{"name":"driver_class","doc":null,"default_value":"","external_name":"driver_class","restriction":"Driver.class"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"drivers[driver_name] = driver_class"}}],"constructors":[],"instance_methods":[],"macros":[{"id":"mapping(properties,strict=true)-macro","html_id":"mapping(properties,strict=true)-macro","name":"mapping","doc":"The `DB.mapping` macro defines how an object is built from a DB::ResultSet.\n\nIt takes hash literal as argument, in which attributes and types are defined.\nOnce defined, `DB::ResultSet#read(t)` populates properties of the class from the\nresult set.\n\n```crystal\nrequire \"db\"\n\nclass Employee\n DB.mapping({\n title: String,\n name: String,\n })\nend\n\nemployees = Employee.from_rs(db.query(\"SELECT title, name FROM employees\"))\nemployees[0].title # => \"Manager\"\nemployees[0].name # => \"John\"\n```\n\nAttributes not mapped with `DB.mapping` are not defined as properties.\nAlso, missing attributes raise a `DB::Exception`.\n\nYou can also define attributes for each property.\n\n```crystal\nclass Employee\n DB.mapping({\n title: String,\n name: {\n type: String,\n nilable: true,\n key: \"firstname\",\n },\n })\nend\n```\n\nAvailable attributes:\n\n* *type* (required) defines its type. In the example above, *title: String* is a shortcut to *title: {type: String}*.\n* *nilable* defines if a property can be a `Nil`.\n* **default**: value to use if the property is missing in the result set, or if it's `null` and `nilable` was not set to `true`. If the default value creates a new instance of an object (for example `[1, 2, 3]` or `SomeObject.new`), a different instance will be used each time a row is parsed.\n* *key* defines which column to read from a reusltset. It defaults to the name of the property.\n* *converter* takes an alternate type for parsing. It requires a `#from_rs` method in that class, and returns an instance of the given type.\n\nThe mapping also automatically defines Crystal properties (getters and setters) for each\nof the keys. It doesn't define a constructor accepting those arguments, but you can provide\nan overload.\n\nThe macro basically defines a constructor accepting a `DB::ResultSet` that reads from\nit and initializes this type's instance variables.\n\nThis macro also declares instance variables of the types given in the mapping.","summary":"

The DB.mapping macro defines how an object is built from a DB::ResultSet.

","abstract":false,"args":[{"name":"properties","doc":null,"default_value":"","external_name":"properties","restriction":""},{"name":"strict","doc":null,"default_value":"true","external_name":"strict","restriction":""}],"args_string":"(properties, strict = true)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/mapping.cr#L60","def":{"name":"mapping","args":[{"name":"properties","doc":null,"default_value":"","external_name":"properties","restriction":""},{"name":"strict","doc":null,"default_value":"true","external_name":"strict","restriction":""}],"double_splat":null,"splat_index":null,"block_arg":null,"visibility":"Public","body":" include ::DB::Mappable\n\n \n{% for key, value in properties %}\n {% unless (value.is_a?(HashLiteral)) || (value.is_a?(NamedTupleLiteral))\n properties[key] = {type: value}\nend %}\n {% end %}\n\n\n \n{% for key, value in properties %}\n {% if (value[:type].is_a?(Generic)) && (value[:type].type_vars.map(&.resolve).includes?(Nil))\n value[:nilable] = true\nend %}\n\n {% if ((value[:type].is_a?(Call)) && (value[:type].name == \"|\")) && ((value[:type].receiver.resolve == Nil) || value[:type].args.map(&.resolve).any?(&.==(Nil))) %}\n {% value[:nilable] = true %}\n {% end %}\n {% end %}\n\n\n \n{% for key, value in properties %}\n @{{ key.id }} : {{ value[:type] }} {{ (value[:nilable] ? \"?\" : \"\").id }}\n\n def {{ key.id }}=(_{{ key.id }} : {{ value[:type] }} {{ (value[:nilable] ? \"?\" : \"\").id }})\n @{{ key.id }} = _{{ key.id }}\n end\n\n def {{ key.id }}\n @{{ key.id }}\n end\n {% end %}\n\n\n def self.from_rs(\n%rs\n : ::DB::ResultSet)\n \n%objs\n = Array(self).new\n \n%rs\n.each do\n \n%objs\n << self.new(\n%rs\n)\n \nend\n \n%objs\n\n \nensure\n \n%rs\n.close\n \nend\n\n def initialize(\n%rs\n : ::DB::ResultSet)\n \n{% for key, value in properties %}\n %var{key.id} = nil\n %found{key.id} = false\n {% end %}\n\n\n \n%rs\n.each_column do |col_name|\n case col_name\n \n{% for key, value in properties %}\n when {{ value[:key] || key.id.stringify }}\n %found{key.id} = true\n %var{key.id} =\n {% if value[:converter] %}\n {{ value[:converter] }}.from_rs(%rs)\n {% else %}{% if value[:nilable] || (value[:default] != nil) %}\n %rs.read(::Union({{ value[:type] }} | Nil))\n {% else %}\n %rs.read({{ value[:type] }})\n {% end %}{% end %}\n {% end %}\n\n \nelse\n \n{% if strict %}\n raise ::DB::MappingException.new(\"unknown result set attribute: #{col_name}\")\n {% else %}\n %rs.read\n {% end %}\n\n \nend\n \nend\n\n \n{% for key, value in properties %}\n {% if value[:nilable] || (value[:default] != nil) %}{% else %}\n if %var{key.id}.is_a?(Nil) && !%found{key.id}\n raise ::DB::MappingException.new(\"missing result set attribute: {{ (value[:key] || key).id }}\")\n end\n {% end %}\n {% end %}\n\n\n \n{% for key, value in properties %}\n {% if value[:nilable] %}\n {% if value[:default] != nil %}\n @{{ key.id }} = %found{key.id} ? %var{key.id} : {{ value[:default] }}\n {% else %}\n @{{ key.id }} = %var{key.id}\n {% end %}\n {% else %}{% if value[:default] != nil %}\n @{{ key.id }} = %var{key.id}.is_a?(Nil) ? {{ value[:default] }} : %var{key.id}\n {% else %}\n @{{ key.id }} = %var{key.id}.as({{ value[:type] }})\n {% end %}{% end %}\n {% end %}\n\n \nend\n \n"}},{"id":"mapping-macro","html_id":"mapping-macro","name":"mapping","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/mapping.cr#L151","def":{"name":"mapping","args":[],"double_splat":{"name":"properties","doc":null,"default_value":"","external_name":"properties","restriction":""},"splat_index":null,"block_arg":null,"visibility":"Public","body":" ::DB.mapping(\n{{ properties }}\n)\n \n"}}],"types":[{"html_id":"github.com/crystal-lang/crystal-db/DB/Any","path":"DB/Any.html","kind":"alias","full_name":"DB::Any","name":"Any","abstract":false,"superclass":null,"ancestors":[],"locations":[{"filename":"db.cr","line_number":75,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":true,"aliased":"(Bool | Float32 | Float64 | Int32 | Int64 | Slice(UInt8) | String | Time | Nil)","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/BeginTransaction","path":"DB/BeginTransaction.html","kind":"module","full_name":"DB::BeginTransaction","name":"BeginTransaction","abstract":false,"superclass":null,"ancestors":[],"locations":[{"filename":"db/begin_transaction.cr","line_number":2,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/begin_transaction.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[{"html_id":"github.com/crystal-lang/crystal-db/DB/Connection","kind":"class","full_name":"DB::Connection","name":"Connection"},{"html_id":"github.com/crystal-lang/crystal-db/DB/Transaction","kind":"class","full_name":"DB::Transaction","name":"Transaction"}],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[{"id":"begin_transaction:Transaction-instance-method","html_id":"begin_transaction:Transaction-instance-method","name":"begin_transaction","doc":"Creates a transaction from the current context.\nIf is expected that either `Transaction#commit` or `Transaction#rollback`\nare called explictly to release the context.","summary":"

Creates a transaction from the current context.

","abstract":true,"args":[],"args_string":" : Transaction","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/begin_transaction.cr#L6","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/begin_transaction.cr#L6","def":{"name":"begin_transaction","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Transaction","visibility":"Public","body":""}},{"id":"transaction(&block)-instance-method","html_id":"transaction(&block)-instance-method","name":"transaction","doc":"yields a transaction from the current context.\nQuery the database through `Transaction#connection` object.\nIf an exception is thrown within the block a rollback is performed.\nThe exception thrown is blubbled unless it is a `DB::Rollback`.\nFrom the yielded object `Transaction#commit` or `Transaction#rollback`\ncan be called explicitly.","summary":"

yields a transaction from the current context.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/begin_transaction.cr#L14","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/begin_transaction.cr#L14","def":{"name":"transaction","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"tx = begin_transaction\nbegin\n yield tx\nrescue e\n if tx.closed?\n else\n tx.rollback\n end\n if e.is_a?(DB::Rollback)\n else\n raise(e)\n end\nelse\n if tx.closed?\n else\n tx.commit\n end\nend\n"}}],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/Connection","path":"DB/Connection.html","kind":"class","full_name":"DB::Connection","name":"Connection","abstract":true,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/DB/BeginTransaction","kind":"module","full_name":"DB::BeginTransaction","name":"BeginTransaction"},{"html_id":"github.com/crystal-lang/crystal-db/DB/SessionMethods","kind":"module","full_name":"DB::SessionMethods","name":"SessionMethods"},{"html_id":"github.com/crystal-lang/crystal-db/DB/QueryMethods","kind":"module","full_name":"DB::QueryMethods","name":"QueryMethods"},{"html_id":"github.com/crystal-lang/crystal-db/DB/Disposable","kind":"module","full_name":"DB::Disposable","name":"Disposable"},{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/connection.cr","line_number":21,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/connection.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/crystal-lang/crystal-db/DB/BeginTransaction","kind":"module","full_name":"DB::BeginTransaction","name":"BeginTransaction"},{"html_id":"github.com/crystal-lang/crystal-db/DB/Disposable","kind":"module","full_name":"DB::Disposable","name":"Disposable"},{"html_id":"github.com/crystal-lang/crystal-db/DB/SessionMethods","kind":"module","full_name":"DB::SessionMethods","name":"SessionMethods"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":"Database driver implementors must subclass `Connection`.\n\nRepresents one active connection to a database.\n\nUsers should never instantiate a `Connection` manually. Use `DB#open` or `Database#connection`.\n\nRefer to `QueryMethods` for documentation about querying the database through this connection.\n\n### Note to implementors\n\nThe connection must be initialized in `#initialize` and closed in `#do_close`.\n\nOverride `#build_prepared_statement` method in order to return a prepared `Statement` to allow querying.\nOverride `#build_unprepared_statement` method in order to return a unprepared `Statement` to allow querying.\nSee also `Statement` to define how the statements are executed.\n\nIf at any give moment the connection is lost a DB::ConnectionLost should be raised. This will\nallow the connection pool to try to reconnect or use another connection if available.\n","summary":"

Database driver implementors must subclass Connection.

","class_methods":[],"constructors":[{"id":"new(context:ConnectionContext)-class-method","html_id":"new(context:ConnectionContext)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"context","doc":null,"default_value":"","external_name":"context","restriction":"ConnectionContext"}],"args_string":"(context : ConnectionContext)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/connection.cr#L34","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/connection.cr#L34","def":{"name":"new","args":[{"name":"context","doc":null,"default_value":"","external_name":"context","restriction":"ConnectionContext"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(context)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"begin_transaction-instance-method","html_id":"begin_transaction-instance-method","name":"begin_transaction","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/connection.cr#L49","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/connection.cr#L49","def":{"name":"begin_transaction","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if @transaction\n raise(DB::Error.new(\"There is an existing transaction in this connection\"))\nend\n@transaction = true\ncreate_transaction\n"}},{"id":"prepared_statements?:Bool-instance-method","html_id":"prepared_statements?:Bool-instance-method","name":"prepared_statements?","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Bool","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/connection.cr#L30","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/connection.cr#L30","def":{"name":"prepared_statements?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Bool","visibility":"Public","body":"@prepared_statements"}},{"id":"release-instance-method","html_id":"release-instance-method","name":"release","doc":"return this connection to the pool\nmanaged by the database. Should be used\nonly if the connection was obtained by `Database#checkout`.","summary":"

return this connection to the pool managed by the database.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/connection.cr#L77","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/connection.cr#L77","def":{"name":"release","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@context.release(self)"}}],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/ConnectionContext","path":"DB/ConnectionContext.html","kind":"module","full_name":"DB::ConnectionContext","name":"ConnectionContext","abstract":false,"superclass":null,"ancestors":[],"locations":[{"filename":"db/connection_context.cr","line_number":2,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/connection_context.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[{"html_id":"github.com/crystal-lang/crystal-db/DB/Database","kind":"class","full_name":"DB::Database","name":"Database"}],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[{"id":"discard(connection:Connection)-instance-method","html_id":"discard(connection:Connection)-instance-method","name":"discard","doc":"Indicates that the *connection* was permanently closed\nand should not be used in the future.","summary":"

Indicates that the connection was permanently closed and should not be used in the future.

","abstract":true,"args":[{"name":"connection","doc":null,"default_value":"","external_name":"connection","restriction":"Connection"}],"args_string":"(connection : Connection)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/connection_context.cr#L11","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/connection_context.cr#L11","def":{"name":"discard","args":[{"name":"connection","doc":null,"default_value":"","external_name":"connection","restriction":"Connection"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"prepared_statements?:Bool-instance-method","html_id":"prepared_statements?:Bool-instance-method","name":"prepared_statements?","doc":"Return whether the statements should be prepared by default","summary":"

Return whether the statements should be prepared by default

","abstract":true,"args":[],"args_string":" : Bool","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/connection_context.cr#L7","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/connection_context.cr#L7","def":{"name":"prepared_statements?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Bool","visibility":"Public","body":""}},{"id":"release(connection:Connection)-instance-method","html_id":"release(connection:Connection)-instance-method","name":"release","doc":"Indicates that the *connection* is no longer needed\nand can be reused in the future.","summary":"

Indicates that the connection is no longer needed and can be reused in the future.

","abstract":true,"args":[{"name":"connection","doc":null,"default_value":"","external_name":"connection","restriction":"Connection"}],"args_string":"(connection : Connection)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/connection_context.cr#L15","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/connection_context.cr#L15","def":{"name":"release","args":[{"name":"connection","doc":null,"default_value":"","external_name":"connection","restriction":"Connection"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"uri:URI-instance-method","html_id":"uri:URI-instance-method","name":"uri","doc":"Returns the uri with the connection settings to the database","summary":"

Returns the uri with the connection settings to the database

","abstract":true,"args":[],"args_string":" : URI","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/connection_context.cr#L4","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/connection_context.cr#L4","def":{"name":"uri","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"URI","visibility":"Public","body":""}}],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/ConnectionLost","path":"DB/ConnectionLost.html","kind":"class","full_name":"DB::ConnectionLost","name":"ConnectionLost","abstract":false,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/DB/Error","kind":"class","full_name":"DB::Error","name":"Error"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/DB/Error","kind":"class","full_name":"DB::Error","name":"Error"},{"html_id":"github.com/crystal-lang/crystal-db/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/error.cr","line_number":17,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/error.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":"Raised when an established connection is lost\nprobably due to socket/network issues.\nIt is used by the connection pool retry logic.","summary":"

Raised when an established connection is lost probably due to socket/network issues.

","class_methods":[],"constructors":[{"id":"new(connection)-class-method","html_id":"new(connection)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"connection","doc":null,"default_value":"","external_name":"connection","restriction":""}],"args_string":"(connection)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/error.cr#L20","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/error.cr#L20","def":{"name":"new","args":[{"name":"connection","doc":null,"default_value":"","external_name":"connection","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(connection)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"connection:Connection-instance-method","html_id":"connection:Connection-instance-method","name":"connection","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Connection","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/error.cr#L18","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/error.cr#L18","def":{"name":"connection","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Connection","visibility":"Public","body":"@connection"}}],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/ConnectionRefused","path":"DB/ConnectionRefused.html","kind":"class","full_name":"DB::ConnectionRefused","name":"ConnectionRefused","abstract":false,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/DB/Error","kind":"class","full_name":"DB::Error","name":"Error"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/DB/Error","kind":"class","full_name":"DB::Error","name":"Error"},{"html_id":"github.com/crystal-lang/crystal-db/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/error.cr","line_number":27,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/error.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":"Raised when a connection is unable to be established\nprobably due to socket/network or configuration issues.\nIt is used by the connection pool retry logic.","summary":"

Raised when a connection is unable to be established probably due to socket/network or configuration issues.

","class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/Database","path":"DB/Database.html","kind":"class","full_name":"DB::Database","name":"Database","abstract":false,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/DB/ConnectionContext","kind":"module","full_name":"DB::ConnectionContext","name":"ConnectionContext"},{"html_id":"github.com/crystal-lang/crystal-db/DB/SessionMethods","kind":"module","full_name":"DB::SessionMethods","name":"SessionMethods"},{"html_id":"github.com/crystal-lang/crystal-db/DB/QueryMethods","kind":"module","full_name":"DB::QueryMethods","name":"QueryMethods"},{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/database.cr","line_number":24,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/database.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/crystal-lang/crystal-db/DB/ConnectionContext","kind":"module","full_name":"DB::ConnectionContext","name":"ConnectionContext"},{"html_id":"github.com/crystal-lang/crystal-db/DB/SessionMethods","kind":"module","full_name":"DB::SessionMethods","name":"SessionMethods"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":"Acts as an entry point for database access.\nConnections are managed by a pool.\nThe connection pool can be configured from URI parameters:\n\n - initial_pool_size (default 1)\n - max_pool_size (default 0 = unlimited)\n - max_idle_pool_size (default 1)\n - checkout_timeout (default 5.0)\n - retry_attempts (default 1)\n - retry_delay (in seconds, default 1.0)\n\nWhen querying a database prepared statements are used by default.\nThis can be changed from the `prepared_statements` URI parameter:\n\n - prepared_statements = `true`|`false` (default `true`)\n\nIt should be created from DB module. See `DB#open`.\n\nRefer to `QueryMethods` and `SessionMethods` for documentation about querying the database.","summary":"

Acts as an entry point for database access.

","class_methods":[],"constructors":[],"instance_methods":[{"id":"checkout-instance-method","html_id":"checkout-instance-method","name":"checkout","doc":"returns a connection from the pool\nthe returned connection must be returned\nto the pool by explictly calling `Connection#release`","summary":"

returns a connection from the pool the returned connection must be returned to the pool by explictly calling Connection#release

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/database.cr#L117","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/database.cr#L117","def":{"name":"checkout","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"connection = @pool.checkout\nconnection.auto_release = false\nconnection\n"}},{"id":"close-instance-method","html_id":"close-instance-method","name":"close","doc":"Closes all connection to the database.","summary":"

Closes all connection to the database.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/database.cr#L65","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/database.cr#L65","def":{"name":"close","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@statements_cache.each_value(&.close)\n@statements_cache.clear\n@pool.close\n"}},{"id":"prepared_statements?:Bool-instance-method","html_id":"prepared_statements?:Bool-instance-method","name":"prepared_statements?","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Bool","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/database.cr#L36","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/database.cr#L36","def":{"name":"prepared_statements?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Bool","visibility":"Public","body":"@prepared_statements"}},{"id":"setup_connection(&proc:Connection->Nil)-instance-method","html_id":"setup_connection(&proc:Connection->Nil)-instance-method","name":"setup_connection","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"(&proc : Connection -> Nil)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/database.cr#L57","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/database.cr#L57","def":{"name":"setup_connection","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"proc","doc":null,"default_value":"","external_name":"proc","restriction":"(Connection -> Nil)"},"return_type":"","visibility":"Public","body":"@setup_connection = proc\n@pool.each_resource do |conn|\n @setup_connection.call(conn)\nend\n"}},{"id":"transaction(&block)-instance-method","html_id":"transaction(&block)-instance-method","name":"transaction","doc":"yields a `Transaction` from a connection of the pool\nRefer to `BeginTransaction#transaction` for documentation.","summary":"

yields a Transaction from a connection of the pool Refer to BeginTransaction#transaction for documentation.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/database.cr#L125","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/database.cr#L125","def":{"name":"transaction","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"using_connection do |cnn|\n cnn.transaction do |tx|\n yield tx\n end\nend"}},{"id":"uri:URI-instance-method","html_id":"uri:URI-instance-method","name":"uri","doc":"Returns the uri with the connection settings to the database","summary":"

Returns the uri with the connection settings to the database

","abstract":false,"args":[],"args_string":" : URI","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/database.cr#L34","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/database.cr#L34","def":{"name":"uri","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@uri"}},{"id":"using_connection(&block)-instance-method","html_id":"using_connection(&block)-instance-method","name":"using_connection","doc":"yields a connection from the pool\nthe connection is returned to the pool\nwhen the block ends","summary":"

yields a connection from the pool the connection is returned to the pool when the block ends

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/database.cr#L105","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/database.cr#L105","def":{"name":"using_connection","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"connection = self.checkout\nbegin\n yield connection\nensure\n connection.release\nend\n"}}],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/Disposable","path":"DB/Disposable.html","kind":"module","full_name":"DB::Disposable","name":"Disposable","abstract":false,"superclass":null,"ancestors":[],"locations":[{"filename":"db/disposable.cr","line_number":3,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/disposable.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[{"html_id":"github.com/crystal-lang/crystal-db/DB/Connection","kind":"class","full_name":"DB::Connection","name":"Connection"},{"html_id":"github.com/crystal-lang/crystal-db/DB/ResultSet","kind":"class","full_name":"DB::ResultSet","name":"ResultSet"},{"html_id":"github.com/crystal-lang/crystal-db/DB/StatementMethods","kind":"module","full_name":"DB::StatementMethods","name":"StatementMethods"},{"html_id":"github.com/crystal-lang/crystal-db/DB/Transaction","kind":"class","full_name":"DB::Transaction","name":"Transaction"}],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":"Generic module to encapsulate disposable db resources.","summary":"

Generic module to encapsulate disposable db resources.

","class_methods":[],"constructors":[],"instance_methods":[{"id":"close-instance-method","html_id":"close-instance-method","name":"close","doc":"Closes this object.","summary":"

Closes this object.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/disposable.cr#L9","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/disposable.cr#L9","def":{"name":"close","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"if @closed\n return\nend\ndo_close\n@closed = true\n"}},{"id":"closed?-instance-method","html_id":"closed?-instance-method","name":"closed?","doc":"Returns `true` if this object is closed. See `#close`.","summary":"

Returns true if this object is closed.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/disposable.cr#L16","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/disposable.cr#L16","def":{"name":"closed?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@closed"}}],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/Driver","path":"DB/Driver.html","kind":"class","full_name":"DB::Driver","name":"Driver","abstract":true,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/driver.cr","line_number":28,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/driver.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":"Database driver implementors must subclass `Driver`,\nregister with a driver_name using `DB#register_driver` and\noverride the factory method `#build_connection`.\n\n```\nrequire \"db\"\n\nclass FakeDriver < DB::Driver\n def build_connection(context : DB::ConnectionContext)\n FakeConnection.new context\n end\nend\n\nDB.register_driver \"fake\", FakeDriver\n```\n\nAccess to this fake datbase will be available with\n\n```\nDB.open \"fake://...\" do |db|\n # ... use db ...\nend\n```\n\nRefer to `Connection`, `Statement` and `ResultSet` for further\ndriver implementation instructions.","summary":"

Database driver implementors must subclass Driver, register with a driver_name using DB#register_driver and override the factory method #build_connection.

","class_methods":[],"constructors":[],"instance_methods":[{"id":"build_connection(context:ConnectionContext):Connection-instance-method","html_id":"build_connection(context:ConnectionContext):Connection-instance-method","name":"build_connection","doc":null,"summary":null,"abstract":true,"args":[{"name":"context","doc":null,"default_value":"","external_name":"context","restriction":"ConnectionContext"}],"args_string":"(context : ConnectionContext) : Connection","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/driver.cr#L29","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/driver.cr#L29","def":{"name":"build_connection","args":[{"name":"context","doc":null,"default_value":"","external_name":"context","restriction":"ConnectionContext"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Connection","visibility":"Public","body":""}},{"id":"connection_pool_options(params:HTTP::Params)-instance-method","html_id":"connection_pool_options(params:HTTP::Params)-instance-method","name":"connection_pool_options","doc":null,"summary":null,"abstract":false,"args":[{"name":"params","doc":null,"default_value":"","external_name":"params","restriction":"HTTP::Params"}],"args_string":"(params : HTTP::Params)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/driver.cr#L31","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/driver.cr#L31","def":{"name":"connection_pool_options","args":[{"name":"params","doc":null,"default_value":"","external_name":"params","restriction":"HTTP::Params"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"{initial_pool_size: (params.fetch(\"initial_pool_size\", 1)).to_i, max_pool_size: (params.fetch(\"max_pool_size\", 0)).to_i, max_idle_pool_size: (params.fetch(\"max_idle_pool_size\", 1)).to_i, checkout_timeout: (params.fetch(\"checkout_timeout\", 5.0)).to_f, retry_attempts: (params.fetch(\"retry_attempts\", 1)).to_i, retry_delay: (params.fetch(\"retry_delay\", 1.0)).to_f}"}}],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/DriverSpecs","path":"DB/DriverSpecs.html","kind":"class","full_name":"DB::DriverSpecs(DBAnyType)","name":"DriverSpecs","abstract":false,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"spec.cr","line_number":51,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":"Helper class to ensure behaviour of custom drivers\n\n```\nrequire \"db/spec\"\n\nDB::DriverSpecs(DB::Any).run do\n # How to connect to database\n connection_string \"scheme://database_url\"\n\n # Clean up database if needed using before/after callbacks\n before do\n # ...\n end\n\n after do\n # ...\n end\n\n # Sample values that will be stored, retrieved across many specs\n sample_value \"hello\", \"varchar(25)\", \"'hello'\"\n\n it \"custom spec with a db initialized\" do |db|\n # assert something using *db*\n end\n\n # Configure the appropiate syntax for different commands needed to run the specs\n binding_syntax do |index|\n \"?\"\n end\n\n create_table_1column_syntax do |table_name, col1|\n \"create table #{table_name} (#{col1.name} #{col1.sql_type} #{col1.null ? \"NULL\" : \"NOT NULL\"})\"\n end\nend\n```\n\nThe following methods needs to be called to configure the appropiate syntax\nfor different commands and allow all the specs to run: `binding_syntax`, `create_table_1column_syntax`,\n`create_table_2columns_syntax`, `select_1column_syntax`, `select_2columns_syntax`, `select_count_syntax`,\n`select_scalar_syntax`, `insert_1column_syntax`, `insert_2columns_syntax`, `drop_table_if_exists_syntax`.\n","summary":"

Helper class to ensure behaviour of custom drivers

","class_methods":[{"id":"run(description="asadb",&block)-class-method","html_id":"run(description=&quot;asadb&quot;,&block)-class-method","name":"run","doc":null,"summary":null,"abstract":false,"args":[{"name":"description","doc":null,"default_value":"\"as a db\"","external_name":"description","restriction":""}],"args_string":"(description = "as a db", &block)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L469","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L469","def":{"name":"run","args":[{"name":"description","doc":null,"default_value":"\"as a db\"","external_name":"description","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"ctx = self.new\nwith ctx yield\ndescribe(description) do\n ctx.include_shared_specs\n ctx.its.each do |db_it|\n case db_it.prepared\n when :default\n it(db_it.description, db_it.file, db_it.line, db_it.end_line) do\n ctx.with_db do |db|\n db_it.block.call(db)\n nil\n end\n end\n when :both\n values = [] of Bool\n if ctx.support_prepared\n values << true\n end\n if ctx.support_unprepared\n values << false\n end\n case values.size\n when 0\n raise(\"Neither prepared non unprepared statements allowed\")\n when 1\n it(db_it.description, db_it.file, db_it.line, db_it.end_line) do\n ctx.with_db do |db|\n db_it.block.call(db)\n nil\n end\n end\n else\n values.each do |prepared_statements|\n it(\"#{db_it.description} (prepared_statements=#{prepared_statements})\", db_it.file, db_it.line, db_it.end_line) do\n ctx.with_db(\"prepared_statements=#{prepared_statements}\") do |db|\n db_it.block.call(db)\n nil\n end\n end\n end\n end\n end\n end\nend\n"}}],"constructors":[],"instance_methods":[{"id":"after(&after:->Nil)-instance-method","html_id":"after(&after:->Nil)-instance-method","name":"after","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"(&after : -> Nil)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L63","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L63","def":{"name":"after","args":[],"double_splat":null,"splat_index":null,"yields":0,"block_arg":{"name":"after","doc":null,"default_value":"","external_name":"after","restriction":"(-> Nil)"},"return_type":"","visibility":"Public","body":"@after = after"}},{"id":"before(&before:->Nil)-instance-method","html_id":"before(&before:->Nil)-instance-method","name":"before","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"(&before : -> Nil)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L60","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L60","def":{"name":"before","args":[],"double_splat":null,"splat_index":null,"yields":0,"block_arg":{"name":"before","doc":null,"default_value":"","external_name":"before","restriction":"(-> Nil)"},"return_type":"","visibility":"Public","body":"@before = before"}},{"id":"binding_syntax(&binding_syntax:Proc(Int32,String))-instance-method","html_id":"binding_syntax(&binding_syntax:Proc(Int32,String))-instance-method","name":"binding_syntax","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"(&binding_syntax : Proc(Int32, String))","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L110","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L110","def":{"name":"binding_syntax","args":[],"double_splat":null,"splat_index":null,"yields":0,"block_arg":{"name":"binding_syntax","doc":null,"default_value":"","external_name":"binding_syntax","restriction":"Proc(Int32, String)"},"return_type":"","visibility":"Public","body":"@binding_syntax = binding_syntax"}},{"id":"connection_string(connection_string:String)-instance-method","html_id":"connection_string(connection_string:String)-instance-method","name":"connection_string","doc":null,"summary":null,"abstract":false,"args":[{"name":"connection_string","doc":null,"default_value":"","external_name":"connection_string","restriction":"String"}],"args_string":"(connection_string : String)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L109","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L109","def":{"name":"connection_string","args":[{"name":"connection_string","doc":null,"default_value":"","external_name":"connection_string","restriction":"String"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@connection_string = connection_string"}},{"id":"create_table_1column_syntax(&create_table_1column_syntax:Proc(String,ColumnDef,String))-instance-method","html_id":"create_table_1column_syntax(&create_table_1column_syntax:Proc(String,ColumnDef,String))-instance-method","name":"create_table_1column_syntax","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"(&create_table_1column_syntax : Proc(String, ColumnDef, String))","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L112","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L112","def":{"name":"create_table_1column_syntax","args":[],"double_splat":null,"splat_index":null,"yields":0,"block_arg":{"name":"create_table_1column_syntax","doc":null,"default_value":"","external_name":"create_table_1column_syntax","restriction":"Proc(String, ColumnDef, String)"},"return_type":"","visibility":"Public","body":"@create_table_1column_syntax = create_table_1column_syntax"}},{"id":"create_table_2columns_syntax(&create_table_2columns_syntax:Proc(String,ColumnDef,ColumnDef,String))-instance-method","html_id":"create_table_2columns_syntax(&create_table_2columns_syntax:Proc(String,ColumnDef,ColumnDef,String))-instance-method","name":"create_table_2columns_syntax","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"(&create_table_2columns_syntax : Proc(String, ColumnDef, ColumnDef, String))","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L113","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L113","def":{"name":"create_table_2columns_syntax","args":[],"double_splat":null,"splat_index":null,"yields":0,"block_arg":{"name":"create_table_2columns_syntax","doc":null,"default_value":"","external_name":"create_table_2columns_syntax","restriction":"Proc(String, ColumnDef, ColumnDef, String)"},"return_type":"","visibility":"Public","body":"@create_table_2columns_syntax = create_table_2columns_syntax"}},{"id":"drop_table_if_exists_syntax(&drop_table_if_exists_syntax:Proc(String,String))-instance-method","html_id":"drop_table_if_exists_syntax(&drop_table_if_exists_syntax:Proc(String,String))-instance-method","name":"drop_table_if_exists_syntax","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"(&drop_table_if_exists_syntax : Proc(String, String))","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L119","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L119","def":{"name":"drop_table_if_exists_syntax","args":[],"double_splat":null,"splat_index":null,"yields":0,"block_arg":{"name":"drop_table_if_exists_syntax","doc":null,"default_value":"","external_name":"drop_table_if_exists_syntax","restriction":"Proc(String, String)"},"return_type":"","visibility":"Public","body":"@drop_table_if_exists_syntax = drop_table_if_exists_syntax"}},{"id":"encode_null(encode_null:String)-instance-method","html_id":"encode_null(encode_null:String)-instance-method","name":"encode_null","doc":null,"summary":null,"abstract":false,"args":[{"name":"encode_null","doc":null,"default_value":"","external_name":"encode_null","restriction":"String"}],"args_string":"(encode_null : String)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L66","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L66","def":{"name":"encode_null","args":[{"name":"encode_null","doc":null,"default_value":"","external_name":"encode_null","restriction":"String"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@encode_null = encode_null"}},{"id":"insert_1column_syntax(&insert_1column_syntax:Proc(String,ColumnDef,String,String))-instance-method","html_id":"insert_1column_syntax(&insert_1column_syntax:Proc(String,ColumnDef,String,String))-instance-method","name":"insert_1column_syntax","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"(&insert_1column_syntax : Proc(String, ColumnDef, String, String))","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L114","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L114","def":{"name":"insert_1column_syntax","args":[],"double_splat":null,"splat_index":null,"yields":0,"block_arg":{"name":"insert_1column_syntax","doc":null,"default_value":"","external_name":"insert_1column_syntax","restriction":"Proc(String, ColumnDef, String, String)"},"return_type":"","visibility":"Public","body":"@insert_1column_syntax = insert_1column_syntax"}},{"id":"insert_2columns_syntax(&insert_2columns_syntax:Proc(String,ColumnDef,String,ColumnDef,String,String))-instance-method","html_id":"insert_2columns_syntax(&insert_2columns_syntax:Proc(String,ColumnDef,String,ColumnDef,String,String))-instance-method","name":"insert_2columns_syntax","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"(&insert_2columns_syntax : Proc(String, ColumnDef, String, ColumnDef, String, String))","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L115","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L115","def":{"name":"insert_2columns_syntax","args":[],"double_splat":null,"splat_index":null,"yields":0,"block_arg":{"name":"insert_2columns_syntax","doc":null,"default_value":"","external_name":"insert_2columns_syntax","restriction":"Proc(String, ColumnDef, String, ColumnDef, String, String)"},"return_type":"","visibility":"Public","body":"@insert_2columns_syntax = insert_2columns_syntax"}},{"id":"it(description="assert",prepared=:default,file=__FILE__,line=__LINE__,end_line=__END_LINE__,&block:DB::Database->)-instance-method","html_id":"it(description=&quot;assert&quot;,prepared=:default,file=__FILE__,line=__LINE__,end_line=__END_LINE__,&block:DB::Database->)-instance-method","name":"it","doc":null,"summary":null,"abstract":false,"args":[{"name":"description","doc":null,"default_value":"\"assert\"","external_name":"description","restriction":""},{"name":"prepared","doc":null,"default_value":":default","external_name":"prepared","restriction":""},{"name":"file","doc":null,"default_value":"__FILE__","external_name":"file","restriction":""},{"name":"line","doc":null,"default_value":"__LINE__","external_name":"line","restriction":""},{"name":"end_line","doc":null,"default_value":"__END_LINE__","external_name":"end_line","restriction":""}],"args_string":"(description = "assert", prepared = :default, file = __FILE__, line = __LINE__, end_line = __END_LINE__, &block : DB::Database -> )","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L125","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L125","def":{"name":"it","args":[{"name":"description","doc":null,"default_value":"\"assert\"","external_name":"description","restriction":""},{"name":"prepared","doc":null,"default_value":":default","external_name":"prepared","restriction":""},{"name":"file","doc":null,"default_value":"__FILE__","external_name":"file","restriction":""},{"name":"line","doc":null,"default_value":"__LINE__","external_name":"line","restriction":""},{"name":"end_line","doc":null,"default_value":"__END_LINE__","external_name":"end_line","restriction":""}],"double_splat":null,"splat_index":null,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(DB::Database -> )"},"return_type":"","visibility":"Public","body":"if Spec.matches?(description, file, line, end_line)\nelse\n return\nend\n@its << (SpecIt.new(description, prepared, file, line, end_line, block))\n"}},{"id":"its-instance-method","html_id":"its-instance-method","name":"its","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L123","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L123","def":{"name":"its","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@its"}},{"id":"sample_value(value,sql_type,value_encoded,*,type_safe_value=true)-instance-method","html_id":"sample_value(value,sql_type,value_encoded,*,type_safe_value=true)-instance-method","name":"sample_value","doc":"Use *value* as sample value that should be stored in columns of type *sql_type*.\n*value_encoded* is driver specific expression that should generate that value in the database.\n*type_safe_value* indicates whether *value_encoded* is expected to generate the *value* even without\nbeen stored in a table (default `true`).","summary":"

Use value as sample value that should be stored in columns of type sql_type.

","abstract":false,"args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""},{"name":"sql_type","doc":null,"default_value":"","external_name":"sql_type","restriction":""},{"name":"value_encoded","doc":null,"default_value":"","external_name":"value_encoded","restriction":""},{"name":"","doc":null,"default_value":"","external_name":"","restriction":""},{"name":"type_safe_value","doc":null,"default_value":"true","external_name":"type_safe_value","restriction":""}],"args_string":"(value, sql_type, value_encoded, *, type_safe_value = true)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L139","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L139","def":{"name":"sample_value","args":[{"name":"value","doc":null,"default_value":"","external_name":"value","restriction":""},{"name":"sql_type","doc":null,"default_value":"","external_name":"sql_type","restriction":""},{"name":"value_encoded","doc":null,"default_value":"","external_name":"value_encoded","restriction":""},{"name":"","doc":null,"default_value":"","external_name":"","restriction":""},{"name":"type_safe_value","doc":null,"default_value":"true","external_name":"type_safe_value","restriction":""}],"double_splat":null,"splat_index":3,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@values << (ValueDef(DBAnyType).new(value, sql_type, value_encoded))\nit(\"select nil as (#{typeof(value)} | Nil)\", prepared: :both) do |db|\n db.query(select_scalar(encode_null, nil)) do |rs|\n assert_single_read(rs, typeof(value || nil), nil)\n end\nend\nvalue_desc = value.to_s\nif value_desc.size > 25\n value_desc = \"#{value_desc[0..25]}...(#{value_desc.size})\"\nend\nvalue_desc = \"#{value_desc} as #{sql_type}\"\nif type_safe_value\n it(\"executes with bind #{value_desc}\") do |db|\n (db.scalar(select_scalar(param(1), sql_type), value)).should(eq(value))\n end\n it(\"executes with bind #{value_desc} as array\") do |db|\n (db.scalar(select_scalar(param(1), sql_type), [value])).should(eq(value))\n end\n it(\"select #{value_desc} as literal\") do |db|\n (db.scalar(select_scalar(value_encoded, sql_type))).should(eq(value))\n db.query(select_scalar(value_encoded, sql_type)) do |rs|\n assert_single_read(rs, typeof(value), value)\n end\n end\nend\nit(\"insert/get value #{value_desc} from table\", prepared: :both) do |db|\n db.exec(sql_create_table_table1(c1 = col1(sql_type)))\n db.exec(sql_insert_table1(c1, value_encoded))\n (db.query_one(sql_select_table1(c1), as: typeof(value))).should(eq(value))\nend\nit(\"insert/get value #{value_desc} from table as nillable\", prepared: :both) do |db|\n db.exec(sql_create_table_table1(c1 = col1(sql_type)))\n db.exec(sql_insert_table1(c1, value_encoded))\n (db.query_one(sql_select_table1(c1), as: ::Union(typeof(value) | Nil))).should(eq(value))\nend\nit(\"insert/get value nil from table as nillable #{sql_type}\", prepared: :both) do |db|\n db.exec(sql_create_table_table1(c1 = col1(sql_type, null: true)))\n db.exec(sql_insert_table1(c1, encode_null))\n (db.query_one(sql_select_table1(c1), as: ::Union(typeof(value) | Nil))).should(eq(nil))\nend\nit(\"insert/get value #{value_desc} from table with binding\") do |db|\n db.exec(sql_create_table_table2(c1 = col1(sql_type_for(String)), c2 = col2(sql_type)))\n db.exec(sql_insert_table2(c1, param(1), c2, param(2)), value_for(String), value)\n (db.query_one(sql_select_table2(c2), as: typeof(value))).should(eq(value))\nend\nit(\"insert/get value #{value_desc} from table as nillable with binding\") do |db|\n db.exec(sql_create_table_table2(c1 = col1(sql_type_for(String)), c2 = col2(sql_type)))\n db.exec(sql_insert_table2(c1, param(1), c2, param(2)), value_for(String), value)\n (db.query_one(sql_select_table2(c2), as: ::Union(typeof(value) | Nil))).should(eq(value))\nend\nit(\"insert/get value nil from table as nillable #{sql_type} with binding\") do |db|\n db.exec(sql_create_table_table2(c1 = col1(sql_type_for(String)), c2 = col2(sql_type, null: true)))\n db.exec(sql_insert_table2(c1, param(1), c2, param(2)), value_for(String), nil)\n (db.query_one(sql_select_table2(c2), as: ::Union(typeof(value) | Nil))).should(eq(nil))\nend\nit(\"can use read(#{typeof(value)}) with DB::ResultSet\", prepared: :both) do |db|\n db.exec(sql_create_table_table1(c1 = col1(sql_type)))\n db.exec(sql_insert_table1(c1, value_encoded))\n db.query(sql_select_table1(c1)) do |rs|\n assert_single_read(rs.as(DB::ResultSet), typeof(value), value)\n end\nend\nit(\"can use read(#{typeof(value)}?) with DB::ResultSet\", prepared: :both) do |db|\n db.exec(sql_create_table_table1(c1 = col1(sql_type)))\n db.exec(sql_insert_table1(c1, value_encoded))\n db.query(sql_select_table1(c1)) do |rs|\n assert_single_read(rs.as(DB::ResultSet), ::Union(typeof(value) | Nil), value)\n end\nend\nit(\"can use read(#{typeof(value)}?) with DB::ResultSet for nil\", prepared: :both) do |db|\n db.exec(sql_create_table_table1(c1 = col1(sql_type, null: true)))\n db.exec(sql_insert_table1(c1, encode_null))\n db.query(sql_select_table1(c1)) do |rs|\n assert_single_read(rs.as(DB::ResultSet), ::Union(typeof(value) | Nil), nil)\n end\nend\n"}},{"id":"select_1column_syntax(&select_1column_syntax:Proc(String,ColumnDef,String))-instance-method","html_id":"select_1column_syntax(&select_1column_syntax:Proc(String,ColumnDef,String))-instance-method","name":"select_1column_syntax","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"(&select_1column_syntax : Proc(String, ColumnDef, String))","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L116","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L116","def":{"name":"select_1column_syntax","args":[],"double_splat":null,"splat_index":null,"yields":0,"block_arg":{"name":"select_1column_syntax","doc":null,"default_value":"","external_name":"select_1column_syntax","restriction":"Proc(String, ColumnDef, String)"},"return_type":"","visibility":"Public","body":"@select_1column_syntax = select_1column_syntax"}},{"id":"select_2columns_syntax(&select_2columns_syntax:Proc(String,ColumnDef,ColumnDef,String))-instance-method","html_id":"select_2columns_syntax(&select_2columns_syntax:Proc(String,ColumnDef,ColumnDef,String))-instance-method","name":"select_2columns_syntax","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"(&select_2columns_syntax : Proc(String, ColumnDef, ColumnDef, String))","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L117","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L117","def":{"name":"select_2columns_syntax","args":[],"double_splat":null,"splat_index":null,"yields":0,"block_arg":{"name":"select_2columns_syntax","doc":null,"default_value":"","external_name":"select_2columns_syntax","restriction":"Proc(String, ColumnDef, ColumnDef, String)"},"return_type":"","visibility":"Public","body":"@select_2columns_syntax = select_2columns_syntax"}},{"id":"select_count_syntax(&select_count_syntax:Proc(String,String))-instance-method","html_id":"select_count_syntax(&select_count_syntax:Proc(String,String))-instance-method","name":"select_count_syntax","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"(&select_count_syntax : Proc(String, String))","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L118","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L118","def":{"name":"select_count_syntax","args":[],"double_splat":null,"splat_index":null,"yields":0,"block_arg":{"name":"select_count_syntax","doc":null,"default_value":"","external_name":"select_count_syntax","restriction":"Proc(String, String)"},"return_type":"","visibility":"Public","body":"@select_count_syntax = select_count_syntax"}},{"id":"select_scalar_syntax(&select_scalar_syntax:Proc(String,String?,String))-instance-method","html_id":"select_scalar_syntax(&select_scalar_syntax:Proc(String,String?,String))-instance-method","name":"select_scalar_syntax","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"(&select_scalar_syntax : Proc(String, String?, String))","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L111","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L111","def":{"name":"select_scalar_syntax","args":[],"double_splat":null,"splat_index":null,"yields":0,"block_arg":{"name":"select_scalar_syntax","doc":null,"default_value":"","external_name":"select_scalar_syntax","restriction":"Proc(String, String | ::Nil, String)"},"return_type":"","visibility":"Public","body":"@select_scalar_syntax = select_scalar_syntax"}},{"id":"support_prepared(support_prepared:Bool)-instance-method","html_id":"support_prepared(support_prepared:Bool)-instance-method","name":"support_prepared","doc":"Allow specs that uses prepared statements (default `true`)","summary":"

Allow specs that uses prepared statements (default true)

","abstract":false,"args":[{"name":"support_prepared","doc":null,"default_value":"","external_name":"support_prepared","restriction":"Bool"}],"args_string":"(support_prepared : Bool)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L70","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L70","def":{"name":"support_prepared","args":[{"name":"support_prepared","doc":null,"default_value":"","external_name":"support_prepared","restriction":"Bool"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@support_prepared = support_prepared"}},{"id":"support_unprepared(support_unprepared:Bool)-instance-method","html_id":"support_unprepared(support_unprepared:Bool)-instance-method","name":"support_unprepared","doc":"Allow specs that uses unprepared statements (default `true`)","summary":"

Allow specs that uses unprepared statements (default true)

","abstract":false,"args":[{"name":"support_unprepared","doc":null,"default_value":"","external_name":"support_unprepared","restriction":"Bool"}],"args_string":"(support_unprepared : Bool)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L79","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L79","def":{"name":"support_unprepared","args":[{"name":"support_unprepared","doc":null,"default_value":"","external_name":"support_unprepared","restriction":"Bool"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@support_unprepared = support_unprepared"}}],"macros":[],"types":[{"html_id":"github.com/crystal-lang/crystal-db/DB/DriverSpecs/ColumnDef","path":"DB/DriverSpecs/ColumnDef.html","kind":"struct","full_name":"DB::DriverSpecs::ColumnDef","name":"ColumnDef","abstract":false,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"github.com/crystal-lang/crystal-db/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"spec.cr","line_number":52,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB/DriverSpecs","kind":"class","full_name":"DB::DriverSpecs(DBAnyType)","name":"DriverSpecs"},"doc":null,"summary":null,"class_methods":[],"constructors":[{"id":"new(name:String,sql_type:String,null:Bool)-class-method","html_id":"new(name:String,sql_type:String,null:Bool)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"name","doc":null,"default_value":"","external_name":"name","restriction":"String"},{"name":"sql_type","doc":null,"default_value":"","external_name":"sql_type","restriction":"String"},{"name":"null","doc":null,"default_value":"","external_name":"null","restriction":"Bool"}],"args_string":"(name : String, sql_type : String, null : Bool)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L52","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L52","def":{"name":"new","args":[{"name":"name","doc":null,"default_value":"","external_name":"name","restriction":"String"},{"name":"sql_type","doc":null,"default_value":"","external_name":"sql_type","restriction":"String"},{"name":"null","doc":null,"default_value":"","external_name":"null","restriction":"Bool"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(name, sql_type, null)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"clone-instance-method","html_id":"clone-instance-method","name":"clone","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L52","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/spec.cr#L52","def":{"name":"clone","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"ColumnDef.new(@name.clone, @sql_type.clone, @null.clone)"}},{"id":"name:String-instance-method","html_id":"name:String-instance-method","name":"name","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : String","source_link":null,"source_link":null,"def":{"name":"name","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"String","visibility":"Public","body":"@name"}},{"id":"null:Bool-instance-method","html_id":"null:Bool-instance-method","name":"null","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Bool","source_link":null,"source_link":null,"def":{"name":"null","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Bool","visibility":"Public","body":"@null"}},{"id":"sql_type:String-instance-method","html_id":"sql_type:String-instance-method","name":"sql_type","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : String","source_link":null,"source_link":null,"def":{"name":"sql_type","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"String","visibility":"Public","body":"@sql_type"}}],"macros":[],"types":[]}]},{"html_id":"github.com/crystal-lang/crystal-db/DB/Error","path":"DB/Error.html","kind":"class","full_name":"DB::Error","name":"Error","abstract":false,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/Exception","kind":"class","full_name":"Exception","name":"Exception"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/error.cr","line_number":2,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/error.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[{"html_id":"github.com/crystal-lang/crystal-db/DB/ConnectionLost","kind":"class","full_name":"DB::ConnectionLost","name":"ConnectionLost"},{"html_id":"github.com/crystal-lang/crystal-db/DB/ConnectionRefused","kind":"class","full_name":"DB::ConnectionRefused","name":"ConnectionRefused"},{"html_id":"github.com/crystal-lang/crystal-db/DB/MappingException","kind":"class","full_name":"DB::MappingException","name":"MappingException"},{"html_id":"github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded","kind":"class","full_name":"DB::PoolRetryAttemptsExceeded","name":"PoolRetryAttemptsExceeded"},{"html_id":"github.com/crystal-lang/crystal-db/DB/PoolTimeout","kind":"class","full_name":"DB::PoolTimeout","name":"PoolTimeout"},{"html_id":"github.com/crystal-lang/crystal-db/DB/Rollback","kind":"class","full_name":"DB::Rollback","name":"Rollback"}],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/ExecResult","path":"DB/ExecResult.html","kind":"struct","full_name":"DB::ExecResult","name":"ExecResult","abstract":false,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"github.com/crystal-lang/crystal-db/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db.cr","line_number":80,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":"Result of a `#exec` statement.","summary":"

Result of a #exec statement.

","class_methods":[],"constructors":[{"id":"new(rows_affected:Int64,last_insert_id:Int64)-class-method","html_id":"new(rows_affected:Int64,last_insert_id:Int64)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"rows_affected","doc":null,"default_value":"","external_name":"rows_affected","restriction":"Int64"},{"name":"last_insert_id","doc":null,"default_value":"","external_name":"last_insert_id","restriction":"Int64"}],"args_string":"(rows_affected : Int64, last_insert_id : Int64)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db.cr#L80","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db.cr#L80","def":{"name":"new","args":[{"name":"rows_affected","doc":null,"default_value":"","external_name":"rows_affected","restriction":"Int64"},{"name":"last_insert_id","doc":null,"default_value":"","external_name":"last_insert_id","restriction":"Int64"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(rows_affected, last_insert_id)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"clone-instance-method","html_id":"clone-instance-method","name":"clone","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db.cr#L80","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db.cr#L80","def":{"name":"clone","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"ExecResult.new(@rows_affected.clone, @last_insert_id.clone)"}},{"id":"last_insert_id:Int64-instance-method","html_id":"last_insert_id:Int64-instance-method","name":"last_insert_id","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Int64","source_link":null,"source_link":null,"def":{"name":"last_insert_id","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int64","visibility":"Public","body":"@last_insert_id"}},{"id":"rows_affected:Int64-instance-method","html_id":"rows_affected:Int64-instance-method","name":"rows_affected","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Int64","source_link":null,"source_link":null,"def":{"name":"rows_affected","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int64","visibility":"Public","body":"@rows_affected"}}],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/Mappable","path":"DB/Mappable.html","kind":"module","full_name":"DB::Mappable","name":"Mappable","abstract":false,"superclass":null,"ancestors":[],"locations":[{"filename":"db/mapping.cr","line_number":3,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/mapping.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":"Empty module used for marking a class as supporting DB:Mapping","summary":"

Empty module used for marking a class as supporting DB:Mapping

","class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/MappingException","path":"DB/MappingException.html","kind":"class","full_name":"DB::MappingException","name":"MappingException","abstract":false,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/DB/Error","kind":"class","full_name":"DB::Error","name":"Error"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/DB/Error","kind":"class","full_name":"DB::Error","name":"Error"},{"html_id":"github.com/crystal-lang/crystal-db/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/error.cr","line_number":5,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/error.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/Pool","path":"DB/Pool.html","kind":"class","full_name":"DB::Pool(T)","name":"Pool","abstract":false,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/pool.cr","line_number":4,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":null,"summary":null,"class_methods":[],"constructors":[{"id":"new(initial_pool_size=1,max_pool_size=0,max_idle_pool_size=1,checkout_timeout=5.0,retry_attempts=1,retry_delay=0.2,&factory:->T)-class-method","html_id":"new(initial_pool_size=1,max_pool_size=0,max_idle_pool_size=1,checkout_timeout=5.0,retry_attempts=1,retry_delay=0.2,&factory:->T)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"initial_pool_size","doc":null,"default_value":"1","external_name":"initial_pool_size","restriction":""},{"name":"max_pool_size","doc":null,"default_value":"0","external_name":"max_pool_size","restriction":""},{"name":"max_idle_pool_size","doc":null,"default_value":"1","external_name":"max_idle_pool_size","restriction":""},{"name":"checkout_timeout","doc":null,"default_value":"5.0","external_name":"checkout_timeout","restriction":""},{"name":"retry_attempts","doc":null,"default_value":"1","external_name":"retry_attempts","restriction":""},{"name":"retry_delay","doc":null,"default_value":"0.2","external_name":"retry_delay","restriction":""}],"args_string":"(initial_pool_size = 1, max_pool_size = 0, max_idle_pool_size = 1, checkout_timeout = 5.0, retry_attempts = 1, retry_delay = 0.2, &factory : -> T)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr#L15","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr#L15","def":{"name":"new","args":[{"name":"initial_pool_size","doc":null,"default_value":"1","external_name":"initial_pool_size","restriction":""},{"name":"max_pool_size","doc":null,"default_value":"0","external_name":"max_pool_size","restriction":""},{"name":"max_idle_pool_size","doc":null,"default_value":"1","external_name":"max_idle_pool_size","restriction":""},{"name":"checkout_timeout","doc":null,"default_value":"5.0","external_name":"checkout_timeout","restriction":""},{"name":"retry_attempts","doc":null,"default_value":"1","external_name":"retry_attempts","restriction":""},{"name":"retry_delay","doc":null,"default_value":"0.2","external_name":"retry_delay","restriction":""}],"double_splat":null,"splat_index":null,"yields":0,"block_arg":{"name":"factory","doc":null,"default_value":"","external_name":"factory","restriction":"(-> T)"},"return_type":"","visibility":"Public","body":"_ = Pool(T).allocate\n_.initialize(initial_pool_size, max_pool_size, max_idle_pool_size, checkout_timeout, retry_attempts, retry_delay, &factory) do\n yield\nend\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"checkout:T-instance-method","html_id":"checkout:T-instance-method","name":"checkout","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : T","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr#L31","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr#L31","def":{"name":"checkout","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"T","visibility":"Public","body":"resource = if @available.empty?\n if can_increase_pool\n build_resource\n else\n wait_for_available\n pick_available\n end\nelse\n pick_available\nend\n@available.delete(resource)\nresource.before_checkout\nresource\n"}},{"id":"checkout_some(candidates:Enumerable(WeakRef(T))):::Tuple(T,Bool)-instance-method","html_id":"checkout_some(candidates:Enumerable(WeakRef(T))):::Tuple(T,Bool)-instance-method","name":"checkout_some","doc":"```\nselected, is_candidate = pool.checkout_some(candidates)\n```\n`selected` be a resource from the `candidates` list and `is_candidate` == `true`\nor `selected` will be a new resource adn `is_candidate` == `false`","summary":"
","abstract":false,"args":[{"name":"candidates","doc":null,"default_value":"","external_name":"candidates","restriction":"Enumerable(WeakRef(T))"}],"args_string":"(candidates : Enumerable(WeakRef(T))) : ::Tuple(T, Bool)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr#L53","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr#L53","def":{"name":"checkout_some","args":[{"name":"candidates","doc":null,"default_value":"","external_name":"candidates","restriction":"Enumerable(WeakRef(T))"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"::Tuple(T, Bool)","visibility":"Public","body":"candidates.each do |ref|\n resource = ref.value\n if resource && (is_available?(resource))\n @available.delete(resource)\n resource.before_checkout\n return {resource, true}\n end\nend\nresource = checkout\n{resource, candidates.any? do |ref|\n ref.value == resource\nend}\n"}},{"id":"close:Nil-instance-method","html_id":"close:Nil-instance-method","name":"close","doc":"close all resources in the pool","summary":"

close all resources in the pool

","abstract":false,"args":[],"args_string":" : Nil","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr#L25","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr#L25","def":{"name":"close","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Nil","visibility":"Public","body":"@total.each(&.close)\n@total.clear\n@available.clear\n"}},{"id":"release(resource:T):Nil-instance-method","html_id":"release(resource:T):Nil-instance-method","name":"release","doc":null,"summary":null,"abstract":false,"args":[{"name":"resource","doc":null,"default_value":"","external_name":"resource","restriction":"T"}],"args_string":"(resource : T) : Nil","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr#L69","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr#L69","def":{"name":"release","args":[{"name":"resource","doc":null,"default_value":"","external_name":"resource","restriction":"T"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Nil","visibility":"Public","body":"if can_increase_idle_pool\n @available << resource\n resource.after_release\n if are_waiting_for_resource?\n @availability_channel.send(nil)\n end\nelse\n resource.close\n @total.delete(resource)\nend"}},{"id":"retry(&block)-instance-method","html_id":"retry(&block)-instance-method","name":"retry","doc":":nodoc:\nWill retry the block if a `ConnectionLost` exception is thrown.\nIt will try to reuse all of the available connection right away,\nbut if a new connection is needed there is a `retry_delay` seconds delay.","summary":"

:nodoc: Will retry the block if a ConnectionLost exception is thrown.

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr#L84","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr#L84","def":{"name":"retry","args":[],"double_splat":null,"splat_index":null,"yields":0,"block_arg":null,"return_type":"","visibility":"Public","body":"current_available = @available.size\nif can_increase_pool\n current_available = current_available + 1\nend\n(current_available + @retry_attempts).times do |i|\n begin\n if i >= current_available\n sleep(@retry_delay)\n end\n return yield\n rescue e : ConnectionLost\n delete(e.connection)\n e.connection.close\n rescue e : ConnectionRefused\n end\nend\nraise(PoolRetryAttemptsExceeded.new)\n"}}],"macros":[],"types":[{"html_id":"github.com/crystal-lang/crystal-db/DB/Pool/TimeoutHelper","path":"DB/Pool/TimeoutHelper.html","kind":"class","full_name":"DB::Pool::TimeoutHelper","name":"TimeoutHelper","abstract":false,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/pool.cr","line_number":183,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB/Pool","kind":"class","full_name":"DB::Pool(T)","name":"Pool"},"doc":null,"summary":null,"class_methods":[],"constructors":[{"id":"new(timeout:Float64)-class-method","html_id":"new(timeout:Float64)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"timeout","doc":null,"default_value":"","external_name":"timeout","restriction":"Float64"}],"args_string":"(timeout : Float64)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr#L184","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr#L184","def":{"name":"new","args":[{"name":"timeout","doc":null,"default_value":"","external_name":"timeout","restriction":"Float64"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(timeout)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"cancel-instance-method","html_id":"cancel-instance-method","name":"cancel","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr#L202","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr#L202","def":{"name":"cancel","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@abort_timeout = true"}},{"id":"receive_select_action-instance-method","html_id":"receive_select_action-instance-method","name":"receive_select_action","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr#L189","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr#L189","def":{"name":"receive_select_action","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@timeout_channel.receive_select_action"}},{"id":"start-instance-method","html_id":"start-instance-method","name":"start","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr#L193","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool.cr#L193","def":{"name":"start","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"spawn do\n sleep(@timeout)\n if @abort_timeout\n else\n @timeout_channel.send(nil)\n end\nend"}}],"macros":[],"types":[]}]},{"html_id":"github.com/crystal-lang/crystal-db/DB/PoolPreparedStatement","path":"DB/PoolPreparedStatement.html","kind":"class","full_name":"DB::PoolPreparedStatement","name":"PoolPreparedStatement","abstract":false,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/DB/PoolStatement","kind":"class","full_name":"DB::PoolStatement","name":"PoolStatement"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/DB/PoolStatement","kind":"class","full_name":"DB::PoolStatement","name":"PoolStatement"},{"html_id":"github.com/crystal-lang/crystal-db/DB/StatementMethods","kind":"module","full_name":"DB::StatementMethods","name":"StatementMethods"},{"html_id":"github.com/crystal-lang/crystal-db/DB/Disposable","kind":"module","full_name":"DB::Disposable","name":"Disposable"},{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/pool_prepared_statement.cr","line_number":7,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_prepared_statement.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":"Represents a statement to be executed in any of the connections\nof the pool. The statement is not be executed in a prepared fashion.\nThe execution of the statement is retried according to the pool configuration.\n\nSee `PoolStatement`","summary":"

Represents a statement to be executed in any of the connections of the pool.

","class_methods":[],"constructors":[{"id":"new(db:Database,query:String)-class-method","html_id":"new(db:Database,query:String)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"db","doc":null,"default_value":"","external_name":"db","restriction":"Database"},{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":"String"}],"args_string":"(db : Database, query : String)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_prepared_statement.cr#L11","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_prepared_statement.cr#L11","def":{"name":"new","args":[{"name":"db","doc":null,"default_value":"","external_name":"db","restriction":"Database"},{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":"String"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(db, query)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/PoolRetryAttemptsExceeded","path":"DB/PoolRetryAttemptsExceeded.html","kind":"class","full_name":"DB::PoolRetryAttemptsExceeded","name":"PoolRetryAttemptsExceeded","abstract":false,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/DB/Error","kind":"class","full_name":"DB::Error","name":"Error"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/DB/Error","kind":"class","full_name":"DB::Error","name":"Error"},{"html_id":"github.com/crystal-lang/crystal-db/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/error.cr","line_number":11,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/error.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/PoolStatement","path":"DB/PoolStatement.html","kind":"class","full_name":"DB::PoolStatement","name":"PoolStatement","abstract":true,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/DB/StatementMethods","kind":"module","full_name":"DB::StatementMethods","name":"StatementMethods"},{"html_id":"github.com/crystal-lang/crystal-db/DB/Disposable","kind":"module","full_name":"DB::Disposable","name":"Disposable"},{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/pool_statement.cr","line_number":6,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_statement.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/crystal-lang/crystal-db/DB/StatementMethods","kind":"module","full_name":"DB::StatementMethods","name":"StatementMethods"}],"extended_modules":[],"subclasses":[{"html_id":"github.com/crystal-lang/crystal-db/DB/PoolPreparedStatement","kind":"class","full_name":"DB::PoolPreparedStatement","name":"PoolPreparedStatement"},{"html_id":"github.com/crystal-lang/crystal-db/DB/PoolUnpreparedStatement","kind":"class","full_name":"DB::PoolUnpreparedStatement","name":"PoolUnpreparedStatement"}],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":"When a statement is to be executed in a DB that has a connection pool\na statement from the DB needs to be able to represent a statement in any\nof the connections of the pool. Otherwise the user will need to deal with\nactual connections in some point.","summary":"

When a statement is to be executed in a DB that has a connection pool a statement from the DB needs to be able to represent a statement in any of the connections of the pool.

","class_methods":[],"constructors":[{"id":"new(db:Database,query:String)-class-method","html_id":"new(db:Database,query:String)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"db","doc":null,"default_value":"","external_name":"db","restriction":"Database"},{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":"String"}],"args_string":"(db : Database, query : String)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_statement.cr#L9","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_statement.cr#L9","def":{"name":"new","args":[{"name":"db","doc":null,"default_value":"","external_name":"db","restriction":"Database"},{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":"String"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(db, query)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"exec(args:Array):ExecResult-instance-method","html_id":"exec(args:Array):ExecResult-instance-method","name":"exec","doc":"See `QueryMethods#exec`","summary":"

See QueryMethods#exec

","abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":"Array"}],"args_string":"(args : Array) : ExecResult","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_statement.cr#L23","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_statement.cr#L23","def":{"name":"exec","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":"Array"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"ExecResult","visibility":"Public","body":"statement_with_retry(&.exec(args))"}},{"id":"exec:ExecResult-instance-method","html_id":"exec:ExecResult-instance-method","name":"exec","doc":"See `QueryMethods#exec`","summary":"

See QueryMethods#exec

","abstract":false,"args":[],"args_string":" : ExecResult","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_statement.cr#L13","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_statement.cr#L13","def":{"name":"exec","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"ExecResult","visibility":"Public","body":"statement_with_retry(&.exec)"}},{"id":"exec(*args):ExecResult-instance-method","html_id":"exec(*args):ExecResult-instance-method","name":"exec","doc":"See `QueryMethods#exec`","summary":"

See QueryMethods#exec

","abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args) : ExecResult","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_statement.cr#L18","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_statement.cr#L18","def":{"name":"exec","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"ExecResult","visibility":"Public","body":"statement_with_retry(&.exec(*args))"}},{"id":"query(args:Array):ResultSet-instance-method","html_id":"query(args:Array):ResultSet-instance-method","name":"query","doc":"See `QueryMethods#query`","summary":"

See QueryMethods#query

","abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":"Array"}],"args_string":"(args : Array) : ResultSet","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_statement.cr#L38","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_statement.cr#L38","def":{"name":"query","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":"Array"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"ResultSet","visibility":"Public","body":"statement_with_retry(&.query(args))"}},{"id":"query:ResultSet-instance-method","html_id":"query:ResultSet-instance-method","name":"query","doc":"See `QueryMethods#query`","summary":"

See QueryMethods#query

","abstract":false,"args":[],"args_string":" : ResultSet","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_statement.cr#L28","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_statement.cr#L28","def":{"name":"query","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"ResultSet","visibility":"Public","body":"statement_with_retry(&.query)"}},{"id":"query(*args):ResultSet-instance-method","html_id":"query(*args):ResultSet-instance-method","name":"query","doc":"See `QueryMethods#query`","summary":"

See QueryMethods#query

","abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args) : ResultSet","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_statement.cr#L33","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_statement.cr#L33","def":{"name":"query","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"ResultSet","visibility":"Public","body":"statement_with_retry(&.query(*args))"}},{"id":"scalar(*args)-instance-method","html_id":"scalar(*args)-instance-method","name":"scalar","doc":"See `QueryMethods#scalar`","summary":"

See QueryMethods#scalar

","abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_statement.cr#L43","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_statement.cr#L43","def":{"name":"scalar","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"statement_with_retry(&.scalar(*args))"}}],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/PoolTimeout","path":"DB/PoolTimeout.html","kind":"class","full_name":"DB::PoolTimeout","name":"PoolTimeout","abstract":false,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/DB/Error","kind":"class","full_name":"DB::Error","name":"Error"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/DB/Error","kind":"class","full_name":"DB::Error","name":"Error"},{"html_id":"github.com/crystal-lang/crystal-db/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/error.cr","line_number":8,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/error.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/PoolUnpreparedStatement","path":"DB/PoolUnpreparedStatement.html","kind":"class","full_name":"DB::PoolUnpreparedStatement","name":"PoolUnpreparedStatement","abstract":false,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/DB/PoolStatement","kind":"class","full_name":"DB::PoolStatement","name":"PoolStatement"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/DB/PoolStatement","kind":"class","full_name":"DB::PoolStatement","name":"PoolStatement"},{"html_id":"github.com/crystal-lang/crystal-db/DB/StatementMethods","kind":"module","full_name":"DB::StatementMethods","name":"StatementMethods"},{"html_id":"github.com/crystal-lang/crystal-db/DB/Disposable","kind":"module","full_name":"DB::Disposable","name":"Disposable"},{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/pool_unprepared_statement.cr","line_number":7,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_unprepared_statement.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":"Represents a statement to be executed in any of the connections\nof the pool. The statement is not be executed in a non prepared fashion.\nThe execution of the statement is retried according to the pool configuration.\n\nSee `PoolStatement`","summary":"

Represents a statement to be executed in any of the connections of the pool.

","class_methods":[],"constructors":[{"id":"new(db:Database,query:String)-class-method","html_id":"new(db:Database,query:String)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"db","doc":null,"default_value":"","external_name":"db","restriction":"Database"},{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":"String"}],"args_string":"(db : Database, query : String)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_unprepared_statement.cr#L8","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/pool_unprepared_statement.cr#L8","def":{"name":"new","args":[{"name":"db","doc":null,"default_value":"","external_name":"db","restriction":"Database"},{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":"String"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(db, query)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/QueryMethods","path":"DB/QueryMethods.html","kind":"module","full_name":"DB::QueryMethods","name":"QueryMethods","abstract":false,"superclass":null,"ancestors":[],"locations":[{"filename":"db/query_methods.cr","line_number":20,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[{"html_id":"github.com/crystal-lang/crystal-db/DB/SessionMethods","kind":"module","full_name":"DB::SessionMethods(Session, Stmt)","name":"SessionMethods"},{"html_id":"github.com/crystal-lang/crystal-db/DB/SessionMethods/PreparedQuery","kind":"struct","full_name":"DB::SessionMethods::PreparedQuery(Session, Stmt)","name":"PreparedQuery"},{"html_id":"github.com/crystal-lang/crystal-db/DB/SessionMethods/UnpreparedQuery","kind":"struct","full_name":"DB::SessionMethods::UnpreparedQuery(Session, Stmt)","name":"UnpreparedQuery"}],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":"Methods to allow querying a database.\nAll methods accepts a `query : String` and a set arguments.\n\nThree kind of statements can be performed:\n 1. `#exec` waits no record response from the database. An `ExecResult` is returned.\n 2. `#scalar` reads a single value of the response. A union of possible values is returned.\n 3. `#query` returns a `ResultSet` that allows iteration over the rows in the response and column information.\n\nArguments can be passed by position\n\n```\ndb.query(\"SELECT name FROM ... WHERE age > ?\", age)\n```\n\nConvention of mapping how arguments are mapped to the query depends on each driver.\n\nIncluding `QueryMethods` requires a `build(query) : Statement` method that is not expected\nto be called directly.","summary":"

Methods to allow querying a database.

","class_methods":[],"constructors":[],"instance_methods":[{"id":"exec(query,*args)-instance-method","html_id":"exec(query,*args)-instance-method","name":"exec","doc":"Performs the `query` and returns an `ExecResult`","summary":"

Performs the #query and returns an ExecResult

","abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(query, *args)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L262","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L262","def":{"name":"exec","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(build(query)).exec(*args)"}},{"id":"query(query,*args)-instance-method","html_id":"query(query,*args)-instance-method","name":"query","doc":"Executes a *query* and returns a `ResultSet` with the results.\nThe `ResultSet` must be closed manually.\n\n```\nresult = db.query \"select name from contacts where id = ?\", 10\nbegin\n if result.move_next\n id = result.read(Int32)\n end\nensure\n result.close\nend\n```","summary":"

Executes a query and returns a ResultSet with the results.

","abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(query, *args)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L37","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L37","def":{"name":"query","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(build(query)).query(*args)"}},{"id":"query(query,*args,&block)-instance-method","html_id":"query(query,*args,&block)-instance-method","name":"query","doc":"Executes a *query* and yields a `ResultSet` with the results.\nThe `ResultSet` is closed automatically.\n\n```\ndb.query(\"select name from contacts where age > ?\", 18) do |rs|\n rs.each do\n name = rs.read(String)\n end\nend\n```","summary":"

Executes a query and yields a ResultSet with the results.

","abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(query, *args, &block)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L51","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L51","def":{"name":"query","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":null,"splat_index":1,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"rs = query(query, *args)\nbegin\n yield rs\nensure\n rs.close\nend\n"}},{"id":"query_all(query,*args,astype:Class)-instance-method","html_id":"query_all(query,*args,astype:Class)-instance-method","name":"query_all","doc":"Executes a *query* and returns an array where the\nvalue of each row is read as the given *type*.\n\n```\nnames = db.query_all \"select name from contacts\", as: String\n```","summary":"

Executes a query and returns an array where the value of each row is read as the given type.

","abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""},{"name":"type","doc":null,"default_value":"","external_name":"as","restriction":"Class"}],"args_string":"(query, *args, as type : Class)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L239","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L239","def":{"name":"query_all","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""},{"name":"type","doc":null,"default_value":"","external_name":"as","restriction":"Class"}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"query_all(query, *args) do |rs|\n rs.read(type)\nend"}},{"id":"query_all(query,*args,astypes:NamedTuple)-instance-method","html_id":"query_all(query,*args,astypes:NamedTuple)-instance-method","name":"query_all","doc":"Executes a *query* and returns an array where each row is\nread as a named tuple of the given *types* (the keys of the named tuple\nare not necessarily the column names).\n\n```\ncontacts = db.query_all \"select name, age from contacts\", as: {name: String, age: Int32}\n```","summary":"

Executes a query and returns an array where each row is read as a named tuple of the given types (the keys of the named tuple are not necessarily the column names).

","abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""},{"name":"types","doc":null,"default_value":"","external_name":"as","restriction":"NamedTuple"}],"args_string":"(query, *args, as types : NamedTuple)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L227","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L227","def":{"name":"query_all","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""},{"name":"types","doc":null,"default_value":"","external_name":"as","restriction":"NamedTuple"}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"query_all(query, *args) do |rs|\n rs.read(**types)\nend"}},{"id":"query_all(query,*args,&block:ResultSet->U):Array(U)forallU-instance-method","html_id":"query_all(query,*args,&block:ResultSet->U):Array(U)forallU-instance-method","name":"query_all","doc":"Executes a *query* and yield a `ResultSet` positioned at the beginning\nof each row, returning an array of the values of the blocks.\n\n```\nnames = db.query_all \"select name from contacts\", &.read(String)\n```","summary":"

Executes a query and yield a ResultSet positioned at the beginning of each row, returning an array of the values of the blocks.

","abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(query, *args, &block : ResultSet -> U) : Array(U) forall U","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L200","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L200","def":{"name":"query_all","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":null,"splat_index":1,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(ResultSet -> U)"},"return_type":"Array(U)","visibility":"Public","body":"ary = [] of U\nquery_each(query, *args) do |rs|\n ary.push(yield rs)\nend\nary\n"}},{"id":"query_all(query,*args,astypes:Tuple)-instance-method","html_id":"query_all(query,*args,astypes:Tuple)-instance-method","name":"query_all","doc":"Executes a *query* and returns an array where each row is\nread as a tuple of the given *types*.\n\n```\ncontacts = db.query_all \"select name, age from contacts\", as: {String, Int32}\n```","summary":"

Executes a query and returns an array where each row is read as a tuple of the given types.

","abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""},{"name":"types","doc":null,"default_value":"","external_name":"as","restriction":"Tuple"}],"args_string":"(query, *args, as types : Tuple)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L214","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L214","def":{"name":"query_all","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""},{"name":"types","doc":null,"default_value":"","external_name":"as","restriction":"Tuple"}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"query_all(query, *args) do |rs|\n rs.read(*types)\nend"}},{"id":"query_each(query,*args,&block)-instance-method","html_id":"query_each(query,*args,&block)-instance-method","name":"query_each","doc":"Executes a *query* and yields the `ResultSet` once per each row.\nThe `ResultSet` is closed automatically.\n\n```\ndb.query_each \"select name from contacts\" do |rs|\n puts rs.read(String)\nend\n```","summary":"

Executes a query and yields the ResultSet once per each row.

","abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(query, *args, &block)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L253","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L253","def":{"name":"query_each","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":null,"splat_index":1,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"query(query, *args) do |rs|\n rs.each do\n yield rs\n end\nend"}},{"id":"query_one(query,*args,&block:ResultSet->U):UforallU-instance-method","html_id":"query_one(query,*args,&block:ResultSet->U):UforallU-instance-method","name":"query_one","doc":"Executes a *query* that expects a single row and yields a `ResultSet`\npositioned at that first row.\n\nThe given block must not invoke `move_next` on the yielded result set.\n\nRaises `DB::Error` if there were no rows, or if there were more than one row.\n\n```\nname = db.query_one \"select name from contacts where id = ?\", 18, &.read(String)\n```","summary":"

Executes a query that expects a single row and yields a ResultSet positioned at that first row.

","abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(query, *args, &block : ResultSet -> U) : U forall U","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L67","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L67","def":{"name":"query_one","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":null,"splat_index":1,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(ResultSet -> U)"},"return_type":"U","visibility":"Public","body":"query(query, *args) do |rs|\n if rs.move_next\n else\n raise(DB::Error.new(\"no rows\"))\n end\n value = yield rs\n if rs.move_next\n raise(DB::Error.new(\"more than one row\"))\n end\n return value\nend"}},{"id":"query_one(query,*args,astypes:Tuple)-instance-method","html_id":"query_one(query,*args,astypes:Tuple)-instance-method","name":"query_one","doc":"Executes a *query* that expects a single row and returns it\nas a tuple of the given *types*.\n\nRaises `DB::Error` if there were no rows, or if there were more than one row.\n\n```\ndb.query_one \"select name, age from contacts where id = ?\", 1, as: {String, Int32}\n```","summary":"

Executes a query that expects a single row and returns it as a tuple of the given types.

","abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""},{"name":"types","doc":null,"default_value":"","external_name":"as","restriction":"Tuple"}],"args_string":"(query, *args, as types : Tuple)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L85","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L85","def":{"name":"query_one","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""},{"name":"types","doc":null,"default_value":"","external_name":"as","restriction":"Tuple"}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"query_one(query, *args) do |rs|\n rs.read(*types)\nend"}},{"id":"query_one(query,*args,astypes:NamedTuple)-instance-method","html_id":"query_one(query,*args,astypes:NamedTuple)-instance-method","name":"query_one","doc":"Executes a *query* that expects a single row and returns it\nas a named tuple of the given *types* (the keys of the named tuple\nare not necessarily the column names).\n\nRaises `DB::Error` if there were no rows, or if there were more than one row.\n\n```\ndb.query_one \"select name, age from contacts where id = ?\", 1, as: {name: String, age: Int32}\n```","summary":"

Executes a query that expects a single row and returns it as a named tuple of the given types (the keys of the named tuple are not necessarily the column names).

","abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""},{"name":"types","doc":null,"default_value":"","external_name":"as","restriction":"NamedTuple"}],"args_string":"(query, *args, as types : NamedTuple)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L100","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L100","def":{"name":"query_one","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""},{"name":"types","doc":null,"default_value":"","external_name":"as","restriction":"NamedTuple"}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"query_one(query, *args) do |rs|\n rs.read(**types)\nend"}},{"id":"query_one(query,*args,astype:Class)-instance-method","html_id":"query_one(query,*args,astype:Class)-instance-method","name":"query_one","doc":"Executes a *query* that expects a single row\nand returns the first column's value as the given *type*.\n\nRaises `DB::Error` if there were no rows, or if there were more than one row.\n\n```\ndb.query_one \"select name from contacts where id = ?\", 1, as: String\n```","summary":"

Executes a query that expects a single row and returns the first column's value as the given type.

","abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""},{"name":"type","doc":null,"default_value":"","external_name":"as","restriction":"Class"}],"args_string":"(query, *args, as type : Class)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L114","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L114","def":{"name":"query_one","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""},{"name":"type","doc":null,"default_value":"","external_name":"as","restriction":"Class"}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"query_one(query, *args) do |rs|\n rs.read(type)\nend"}},{"id":"query_one?(query,*args,astype:Class)-instance-method","html_id":"query_one?(query,*args,astype:Class)-instance-method","name":"query_one?","doc":"Executes a *query* that expects a single row\nand returns the first column's value as the given *type*.\n\nReturns `nil` if there were no rows.\n\nRaises `DB::Error` if there were more than one row.\n\n```\nname = db.query_one? \"select name from contacts where id = ?\", 1, as: String\ntypeof(name) # => String?\n```","summary":"

Executes a query that expects a single row and returns the first column's value as the given type.

","abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""},{"name":"type","doc":null,"default_value":"","external_name":"as","restriction":"Class"}],"args_string":"(query, *args, as type : Class)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L188","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L188","def":{"name":"query_one?","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""},{"name":"type","doc":null,"default_value":"","external_name":"as","restriction":"Class"}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"query_one?(query, *args) do |rs|\n rs.read(type)\nend"}},{"id":"query_one?(query,*args,astypes:NamedTuple)-instance-method","html_id":"query_one?(query,*args,astypes:NamedTuple)-instance-method","name":"query_one?","doc":"Executes a *query* that expects a single row and returns it\nas a named tuple of the given *types* (the keys of the named tuple\nare not necessarily the column names).\n\nReturns `nil` if there were no rows.\n\nRaises `DB::Error` if there were more than one row.\n\n```\nresult = db.query_one? \"select name, age from contacts where id = ?\", 1, as: {age: String, name: Int32}\ntypeof(result) # => NamedTuple(age: String, name: Int32) | Nil\n```","summary":"

Executes a query that expects a single row and returns it as a named tuple of the given types (the keys of the named tuple are not necessarily the column names).

","abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""},{"name":"types","doc":null,"default_value":"","external_name":"as","restriction":"NamedTuple"}],"args_string":"(query, *args, as types : NamedTuple)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L171","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L171","def":{"name":"query_one?","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""},{"name":"types","doc":null,"default_value":"","external_name":"as","restriction":"NamedTuple"}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"query_one(query, *args) do |rs|\n rs.read(**types)\nend"}},{"id":"query_one?(query,*args,astypes:Tuple)-instance-method","html_id":"query_one?(query,*args,astypes:Tuple)-instance-method","name":"query_one?","doc":"Executes a *query* that expects a single row and returns it\nas a tuple of the given *types*.\n\nReturns `nil` if there were no rows.\n\nRaises `DB::Error` if there were more than one row.\n\n```\nresult = db.query_one? \"select name, age from contacts where id = ?\", 1, as: {String, Int32}\ntypeof(result) # => Tuple(String, Int32) | Nil\n```","summary":"

Executes a query that expects a single row and returns it as a tuple of the given types.

","abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""},{"name":"types","doc":null,"default_value":"","external_name":"as","restriction":"Tuple"}],"args_string":"(query, *args, as types : Tuple)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L153","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L153","def":{"name":"query_one?","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""},{"name":"types","doc":null,"default_value":"","external_name":"as","restriction":"Tuple"}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"query_one?(query, *args) do |rs|\n rs.read(*types)\nend"}},{"id":"query_one?(query,*args,&block:ResultSet->U):U?forallU-instance-method","html_id":"query_one?(query,*args,&block:ResultSet->U):U?forallU-instance-method","name":"query_one?","doc":"Executes a *query* that expects at most a single row and yields a `ResultSet`\npositioned at that first row.\n\nReturns `nil`, not invoking the block, if there were no rows.\n\nRaises `DB::Error` if there were more than one row\n(this ends up invoking the block once).\n\n```\nname = db.query_one? \"select name from contacts where id = ?\", 18, &.read(String)\ntypeof(name) # => String | Nil\n```","summary":"

Executes a query that expects at most a single row and yields a ResultSet positioned at that first row.

","abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(query, *args, &block : ResultSet -> U) : U? forall U","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L132","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L132","def":{"name":"query_one?","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":null,"splat_index":1,"yields":1,"block_arg":{"name":"block","doc":null,"default_value":"","external_name":"block","restriction":"(ResultSet -> U)"},"return_type":"U | ::Nil","visibility":"Public","body":"query(query, *args) do |rs|\n if rs.move_next\n else\n return nil\n end\n value = yield rs\n if rs.move_next\n raise(DB::Error.new(\"more than one row\"))\n end\n return value\nend"}},{"id":"scalar(query,*args)-instance-method","html_id":"scalar(query,*args)-instance-method","name":"scalar","doc":"Performs the `query` and returns a single scalar value\nputs db.scalar(\"SELECT MAX(name)\").as(String) # => (a String)","summary":"

Performs the #query and returns a single scalar value puts db.scalar(\"SELECT MAX(name)\").as(String) # => (a String)

","abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(query, *args)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L268","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/query_methods.cr#L268","def":{"name":"scalar","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""},{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":null,"splat_index":1,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"(build(query)).scalar(*args)"}}],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/ResultSet","path":"DB/ResultSet.html","kind":"class","full_name":"DB::ResultSet","name":"ResultSet","abstract":true,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/DB/Disposable","kind":"module","full_name":"DB::Disposable","name":"Disposable"},{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/result_set.cr","line_number":22,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/crystal-lang/crystal-db/DB/Disposable","kind":"module","full_name":"DB::Disposable","name":"Disposable"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":"The response of a query performed on a `Database`.\n\nSee `DB` for a complete sample.\n\nEach `#read` call consumes the result and moves to the next column.\nEach column must be read in order.\nAt any moment a `#move_next` can be invoked, meaning to skip the\nremaining, or even all the columns, in the current row.\nAlso it is not mandatory to consume the whole `ResultSet`, hence an iteration\nthrough `#each` or `#move_next` can be stopped.\n\n**Note:** depending on how the `ResultSet` was obtained it might be mandatory an\nexplicit call to `#close`. Check `QueryMethods#query`.\n\n### Note to implementors\n\n1. Override `#move_next` to move to the next row.\n2. Override `#read` returning the next value in the row.\n3. (Optional) Override `#read(t)` for some types `t` for which custom logic other than a simple cast is needed.\n4. Override `#column_count`, `#column_name`.","summary":"

The response of a query performed on a Database.

","class_methods":[],"constructors":[{"id":"new(statement:DB::Statement)-class-method","html_id":"new(statement:DB::Statement)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"statement","doc":null,"default_value":"","external_name":"statement","restriction":"DB::Statement"}],"args_string":"(statement : DB::Statement)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L28","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L28","def":{"name":"new","args":[{"name":"statement","doc":null,"default_value":"","external_name":"statement","restriction":"DB::Statement"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(statement)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"column_count:Int32-instance-method","html_id":"column_count:Int32-instance-method","name":"column_count","doc":"Returns the number of columns in the result","summary":"

Returns the number of columns in the result

","abstract":true,"args":[],"args_string":" : Int32","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L59","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L59","def":{"name":"column_count","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Int32","visibility":"Public","body":""}},{"id":"column_name(index:Int32):String-instance-method","html_id":"column_name(index:Int32):String-instance-method","name":"column_name","doc":"Returns the name of the column in `index` 0-based position.","summary":"

Returns the name of the column in index 0-based position.

","abstract":true,"args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int32"}],"args_string":"(index : Int32) : String","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L62","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L62","def":{"name":"column_name","args":[{"name":"index","doc":null,"default_value":"","external_name":"index","restriction":"Int32"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"String","visibility":"Public","body":""}},{"id":"column_names-instance-method","html_id":"column_names-instance-method","name":"column_names","doc":"Returns the name of the columns.","summary":"

Returns the name of the columns.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L65","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L65","def":{"name":"column_names","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"Array(String).new(column_count) do |i|\n column_name(i)\nend"}},{"id":"each(&block)-instance-method","html_id":"each(&block)-instance-method","name":"each","doc":"Iterates over all the rows","summary":"

Iterates over all the rows

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L38","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L38","def":{"name":"each","args":[],"double_splat":null,"splat_index":null,"yields":0,"block_arg":null,"return_type":"","visibility":"Public","body":"while move_next\n yield\nend"}},{"id":"each_column(&block)-instance-method","html_id":"each_column(&block)-instance-method","name":"each_column","doc":"Iterates over all the columns","summary":"

Iterates over all the columns

","abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L45","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L45","def":{"name":"each_column","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"column_count.times do |x|\n yield column_name(x)\nend"}},{"id":"move_next:Bool-instance-method","html_id":"move_next:Bool-instance-method","name":"move_next","doc":"Move the next row in the result.\nReturn `false` if no more rows are available.\nSee `#each`","summary":"

Move the next row in the result.

","abstract":true,"args":[],"args_string":" : Bool","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L54","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L54","def":{"name":"move_next","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Bool","visibility":"Public","body":""}},{"id":"read(type:DB::Mappable.class)-instance-method","html_id":"read(type:DB::Mappable.class)-instance-method","name":"read","doc":"Reads the next columns and maps them to a class","summary":"

Reads the next columns and maps them to a class

","abstract":false,"args":[{"name":"type","doc":null,"default_value":"","external_name":"type","restriction":"DB::Mappable.class"}],"args_string":"(type : DB::Mappable.class)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L73","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L73","def":{"name":"read","args":[{"name":"type","doc":null,"default_value":"","external_name":"type","restriction":"DB::Mappable.class"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"type.new(self)"}},{"id":"read(type:T.class):TforallT-instance-method","html_id":"read(type:T.class):TforallT-instance-method","name":"read","doc":"Reads the next column value as a **type**","summary":"

Reads the next column value as a type

","abstract":false,"args":[{"name":"type","doc":null,"default_value":"","external_name":"type","restriction":"T.class"}],"args_string":"(type : T.class) : T forall T","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L78","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L78","def":{"name":"read","args":[{"name":"type","doc":null,"default_value":"","external_name":"type","restriction":"T.class"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"T","visibility":"Public","body":"value = read\nif value.is_a?(T)\n value\nelse\n raise(\"#{self.class}#read returned a #{value.class}. A #{T} was expected.\")\nend\n"}},{"id":"read-instance-method","html_id":"read-instance-method","name":"read","doc":"Reads the next columns and returns a named tuple of the values.","summary":"

Reads the next columns and returns a named tuple of the values.

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L93","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L93","def":{"name":"read","args":[],"double_splat":{"name":"types","doc":null,"default_value":"","external_name":"types","restriction":"Class"},"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"internal_read(**types)"}},{"id":"read-instance-method","html_id":"read-instance-method","name":"read","doc":"Reads the next column value","summary":"

Reads the next column value

","abstract":true,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L70","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L70","def":{"name":"read","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"read(*types:Class)-instance-method","html_id":"read(*types:Class)-instance-method","name":"read","doc":"Reads the next columns and returns a tuple of the values.","summary":"

Reads the next columns and returns a tuple of the values.

","abstract":false,"args":[{"name":"types","doc":null,"default_value":"","external_name":"types","restriction":"Class"}],"args_string":"(*types : Class)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L88","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/result_set.cr#L88","def":{"name":"read","args":[{"name":"types","doc":null,"default_value":"","external_name":"types","restriction":"Class"}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"internal_read(*types)"}}],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/Rollback","path":"DB/Rollback.html","kind":"class","full_name":"DB::Rollback","name":"Rollback","abstract":false,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/DB/Error","kind":"class","full_name":"DB::Error","name":"Error"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/DB/Error","kind":"class","full_name":"DB::Error","name":"Error"},{"html_id":"github.com/crystal-lang/crystal-db/Exception","kind":"class","full_name":"Exception","name":"Exception"},{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/error.cr","line_number":30,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/error.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/SavePointTransaction","path":"DB/SavePointTransaction.html","kind":"class","full_name":"DB::SavePointTransaction","name":"SavePointTransaction","abstract":false,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/DB/Transaction","kind":"class","full_name":"DB::Transaction","name":"Transaction"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/DB/Transaction","kind":"class","full_name":"DB::Transaction","name":"Transaction"},{"html_id":"github.com/crystal-lang/crystal-db/DB/BeginTransaction","kind":"module","full_name":"DB::BeginTransaction","name":"BeginTransaction"},{"html_id":"github.com/crystal-lang/crystal-db/DB/Disposable","kind":"module","full_name":"DB::Disposable","name":"Disposable"},{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/transaction.cr","line_number":94,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":null,"summary":null,"class_methods":[],"constructors":[{"id":"new(parent:Transaction,savepoint_name:String)-class-method","html_id":"new(parent:Transaction,savepoint_name:String)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"parent","doc":null,"default_value":"","external_name":"parent","restriction":"Transaction"},{"name":"savepoint_name","doc":null,"default_value":"","external_name":"savepoint_name","restriction":"String"}],"args_string":"(parent : Transaction, savepoint_name : String)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L97","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L97","def":{"name":"new","args":[{"name":"parent","doc":null,"default_value":"","external_name":"parent","restriction":"Transaction"},{"name":"savepoint_name","doc":null,"default_value":"","external_name":"savepoint_name","restriction":"String"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(parent, savepoint_name)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"begin_transaction:Transaction-instance-method","html_id":"begin_transaction:Transaction-instance-method","name":"begin_transaction","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Transaction","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L117","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L117","def":{"name":"begin_transaction","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Transaction","visibility":"Public","body":"if @nested_transaction\n raise(DB::Error.new(\"There is an existing nested transaction in this transaction\"))\nend\n@nested_transaction = true\ncreate_save_point_transaction(self)\n"}},{"id":"commit-instance-method","html_id":"commit-instance-method","name":"commit","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L103","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L103","def":{"name":"commit","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@connection.perform_release_savepoint(@savepoint_name)\nsuper()\n"}},{"id":"connection:Connection-instance-method","html_id":"connection:Connection-instance-method","name":"connection","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Connection","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L95","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L95","def":{"name":"connection","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Connection","visibility":"Public","body":"@connection"}},{"id":"create_save_point_transaction(parent:Transaction)-instance-method","html_id":"create_save_point_transaction(parent:Transaction)-instance-method","name":"create_save_point_transaction","doc":null,"summary":null,"abstract":false,"args":[{"name":"parent","doc":null,"default_value":"","external_name":"parent","restriction":"Transaction"}],"args_string":"(parent : Transaction)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L123","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L123","def":{"name":"create_save_point_transaction","args":[{"name":"parent","doc":null,"default_value":"","external_name":"parent","restriction":"Transaction"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@parent.create_save_point_transaction(parent)"}},{"id":"release_from_nested_transaction-instance-method","html_id":"release_from_nested_transaction-instance-method","name":"release_from_nested_transaction","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L127","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L127","def":{"name":"release_from_nested_transaction","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@nested_transaction = false"}},{"id":"rollback-instance-method","html_id":"rollback-instance-method","name":"rollback","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L108","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L108","def":{"name":"rollback","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@connection.perform_rollback_savepoint(@savepoint_name)\nsuper()\n"}}],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/SessionMethods","path":"DB/SessionMethods.html","kind":"module","full_name":"DB::SessionMethods(Session, Stmt)","name":"SessionMethods","abstract":false,"superclass":null,"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/DB/QueryMethods","kind":"module","full_name":"DB::QueryMethods","name":"QueryMethods"}],"locations":[{"filename":"db/session_methods.cr","line_number":10,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/crystal-lang/crystal-db/DB/QueryMethods","kind":"module","full_name":"DB::QueryMethods","name":"QueryMethods"}],"extended_modules":[],"subclasses":[],"including_types":[{"html_id":"github.com/crystal-lang/crystal-db/DB/Connection","kind":"class","full_name":"DB::Connection","name":"Connection"},{"html_id":"github.com/crystal-lang/crystal-db/DB/Database","kind":"class","full_name":"DB::Database","name":"Database"}],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":"Methods that are shared accross session like objects:\n - Database\n - Connection\n\nClasses that includes this module are able to execute\nqueries and statements in both prepared and unprepared fashion.\n\nThis module serves for dsl reuse over session like objects.","summary":"

Methods that are shared accross session like objects: - Database - Connection

","class_methods":[],"constructors":[],"instance_methods":[{"id":"build(query):Stmt-instance-method","html_id":"build(query):Stmt-instance-method","name":"build","doc":null,"summary":null,"abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""}],"args_string":"(query) : Stmt","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L21","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L21","def":{"name":"build","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Stmt","visibility":"Public","body":"if prepared_statements?\n fetch_or_build_prepared_statement(query)\nelse\n build_unprepared_statement(query)\nend"}},{"id":"build_unprepared_statement(query):Stmt-instance-method","html_id":"build_unprepared_statement(query):Stmt-instance-method","name":"build_unprepared_statement","doc":null,"summary":null,"abstract":true,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""}],"args_string":"(query) : Stmt","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L19","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L19","def":{"name":"build_unprepared_statement","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Stmt","visibility":"Public","body":""}},{"id":"fetch_or_build_prepared_statement(query):Stmt-instance-method","html_id":"fetch_or_build_prepared_statement(query):Stmt-instance-method","name":"fetch_or_build_prepared_statement","doc":null,"summary":null,"abstract":true,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""}],"args_string":"(query) : Stmt","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L17","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L17","def":{"name":"fetch_or_build_prepared_statement","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Stmt","visibility":"Public","body":""}},{"id":"prepared(query)-instance-method","html_id":"prepared(query)-instance-method","name":"prepared","doc":"Returns a prepared `Statement` that has not been executed yet.","summary":"

Returns a prepared Statement that has not been executed yet.

","abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""}],"args_string":"(query)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L36","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L36","def":{"name":"prepared","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"prepared.build(query)"}},{"id":"prepared-instance-method","html_id":"prepared-instance-method","name":"prepared","doc":"dsl helper to build prepared statements\nreturns a value that includes `QueryMethods`","summary":"

dsl helper to build prepared statements returns a value that includes QueryMethods

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L31","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L31","def":{"name":"prepared","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"PreparedQuery(Session, Stmt).new(self)"}},{"id":"prepared_statements?:Bool-instance-method","html_id":"prepared_statements?:Bool-instance-method","name":"prepared_statements?","doc":"Returns whether by default the statements should\nbe prepared or not.","summary":"

Returns whether by default the statements should be prepared or not.

","abstract":true,"args":[],"args_string":" : Bool","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L15","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L15","def":{"name":"prepared_statements?","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Bool","visibility":"Public","body":""}},{"id":"unprepared(query)-instance-method","html_id":"unprepared(query)-instance-method","name":"unprepared","doc":"Returns an unprepared `Statement` that has not been executed yet.","summary":"

Returns an unprepared Statement that has not been executed yet.

","abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""}],"args_string":"(query)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L47","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L47","def":{"name":"unprepared","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"unprepared.build(query)"}},{"id":"unprepared-instance-method","html_id":"unprepared-instance-method","name":"unprepared","doc":"dsl helper to build unprepared statements\nreturns a value that includes `QueryMethods`","summary":"

dsl helper to build unprepared statements returns a value that includes QueryMethods

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L42","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L42","def":{"name":"unprepared","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"UnpreparedQuery(Session, Stmt).new(self)"}}],"macros":[],"types":[{"html_id":"github.com/crystal-lang/crystal-db/DB/SessionMethods/PreparedQuery","path":"DB/SessionMethods/PreparedQuery.html","kind":"struct","full_name":"DB::SessionMethods::PreparedQuery(Session, Stmt)","name":"PreparedQuery","abstract":false,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/DB/QueryMethods","kind":"module","full_name":"DB::QueryMethods","name":"QueryMethods"},{"html_id":"github.com/crystal-lang/crystal-db/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"github.com/crystal-lang/crystal-db/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/session_methods.cr","line_number":51,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/crystal-lang/crystal-db/DB/QueryMethods","kind":"module","full_name":"DB::QueryMethods","name":"QueryMethods"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB/SessionMethods","kind":"module","full_name":"DB::SessionMethods(Session, Stmt)","name":"SessionMethods"},"doc":null,"summary":null,"class_methods":[],"constructors":[{"id":"new(session:Session)-class-method","html_id":"new(session:Session)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"session","doc":null,"default_value":"","external_name":"session","restriction":"Session"}],"args_string":"(session : Session)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L54","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L54","def":{"name":"new","args":[{"name":"session","doc":null,"default_value":"","external_name":"session","restriction":"Session"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = PreparedQuery(Session, Stmt).allocate\n_.initialize(session)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"build(query):Stmt-instance-method","html_id":"build(query):Stmt-instance-method","name":"build","doc":null,"summary":null,"abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""}],"args_string":"(query) : Stmt","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L57","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L57","def":{"name":"build","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Stmt","visibility":"Public","body":"@session.fetch_or_build_prepared_statement(query)"}}],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/SessionMethods/UnpreparedQuery","path":"DB/SessionMethods/UnpreparedQuery.html","kind":"struct","full_name":"DB::SessionMethods::UnpreparedQuery(Session, Stmt)","name":"UnpreparedQuery","abstract":false,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/Struct","kind":"struct","full_name":"Struct","name":"Struct"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/DB/QueryMethods","kind":"module","full_name":"DB::QueryMethods","name":"QueryMethods"},{"html_id":"github.com/crystal-lang/crystal-db/Struct","kind":"struct","full_name":"Struct","name":"Struct"},{"html_id":"github.com/crystal-lang/crystal-db/Value","kind":"struct","full_name":"Value","name":"Value"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/session_methods.cr","line_number":62,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/crystal-lang/crystal-db/DB/QueryMethods","kind":"module","full_name":"DB::QueryMethods","name":"QueryMethods"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB/SessionMethods","kind":"module","full_name":"DB::SessionMethods(Session, Stmt)","name":"SessionMethods"},"doc":null,"summary":null,"class_methods":[],"constructors":[{"id":"new(session:Session)-class-method","html_id":"new(session:Session)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"session","doc":null,"default_value":"","external_name":"session","restriction":"Session"}],"args_string":"(session : Session)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L65","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L65","def":{"name":"new","args":[{"name":"session","doc":null,"default_value":"","external_name":"session","restriction":"Session"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = UnpreparedQuery(Session, Stmt).allocate\n_.initialize(session)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"build(query):Stmt-instance-method","html_id":"build(query):Stmt-instance-method","name":"build","doc":null,"summary":null,"abstract":false,"args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""}],"args_string":"(query) : Stmt","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L68","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/session_methods.cr#L68","def":{"name":"build","args":[{"name":"query","doc":null,"default_value":"","external_name":"query","restriction":""}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Stmt","visibility":"Public","body":"@session.build_unprepared_statement(query)"}}],"macros":[],"types":[]}]},{"html_id":"github.com/crystal-lang/crystal-db/DB/Statement","path":"DB/Statement.html","kind":"class","full_name":"DB::Statement","name":"Statement","abstract":true,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/DB/StatementMethods","kind":"module","full_name":"DB::StatementMethods","name":"StatementMethods"},{"html_id":"github.com/crystal-lang/crystal-db/DB/Disposable","kind":"module","full_name":"DB::Disposable","name":"Disposable"},{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/statement.cr","line_number":52,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/crystal-lang/crystal-db/DB/StatementMethods","kind":"module","full_name":"DB::StatementMethods","name":"StatementMethods"}],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":"Represents a query in a `Connection`.\nIt should be created by `QueryMethods`.\n\n### Note to implementors\n\n1. Subclass `Statements`\n2. `Statements` are created from a custom driver `Connection#prepare` method.\n3. `#perform_query` executes a query that is expected to return a `ResultSet`\n4. `#perform_exec` executes a query that is expected to return an `ExecResult`\n6. `#do_close` is called to release the statement resources.","summary":"

Represents a query in a Connection.

","class_methods":[],"constructors":[{"id":"new(connection:Connection)-class-method","html_id":"new(connection:Connection)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"connection","doc":null,"default_value":"","external_name":"connection","restriction":"Connection"}],"args_string":"(connection : Connection)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L58","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L58","def":{"name":"new","args":[{"name":"connection","doc":null,"default_value":"","external_name":"connection","restriction":"Connection"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(connection)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"exec(args:Array)-instance-method","html_id":"exec(args:Array)-instance-method","name":"exec","doc":"See `QueryMethods#exec`","summary":"

See QueryMethods#exec

","abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":"Array"}],"args_string":"(args : Array)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L71","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L71","def":{"name":"exec","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":"Array"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"perform_exec_and_release(args)"}},{"id":"exec-instance-method","html_id":"exec-instance-method","name":"exec","doc":"See `QueryMethods#exec`","summary":"

See QueryMethods#exec

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L66","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L66","def":{"name":"exec","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"perform_exec_and_release(Slice(Any).empty)"}},{"id":"exec(*args)-instance-method","html_id":"exec(*args)-instance-method","name":"exec","doc":"See `QueryMethods#exec`","summary":"

See QueryMethods#exec

","abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L76","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L76","def":{"name":"exec","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"perform_exec_and_release(args)"}},{"id":"query(args:Array)-instance-method","html_id":"query(args:Array)-instance-method","name":"query","doc":"See `QueryMethods#query`","summary":"

See QueryMethods#query

","abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":"Array"}],"args_string":"(args : Array)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L87","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L87","def":{"name":"query","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":"Array"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"perform_query_with_rescue(args)"}},{"id":"query-instance-method","html_id":"query-instance-method","name":"query","doc":"See `QueryMethods#query`","summary":"

See QueryMethods#query

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L82","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L82","def":{"name":"query","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"perform_query_with_rescue(Tuple.new)"}},{"id":"query(*args)-instance-method","html_id":"query(*args)-instance-method","name":"query","doc":"See `QueryMethods#query`","summary":"

See QueryMethods#query

","abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L92","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L92","def":{"name":"query","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"perform_query_with_rescue(args)"}},{"id":"release_connection-instance-method","html_id":"release_connection-instance-method","name":"release_connection","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L61","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L61","def":{"name":"release_connection","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@connection.release_from_statement"}}],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/StatementMethods","path":"DB/StatementMethods.html","kind":"module","full_name":"DB::StatementMethods","name":"StatementMethods","abstract":false,"superclass":null,"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/DB/Disposable","kind":"module","full_name":"DB::Disposable","name":"Disposable"}],"locations":[{"filename":"db/statement.cr","line_number":4,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/crystal-lang/crystal-db/DB/Disposable","kind":"module","full_name":"DB::Disposable","name":"Disposable"}],"extended_modules":[],"subclasses":[],"including_types":[{"html_id":"github.com/crystal-lang/crystal-db/DB/PoolStatement","kind":"class","full_name":"DB::PoolStatement","name":"PoolStatement"},{"html_id":"github.com/crystal-lang/crystal-db/DB/Statement","kind":"class","full_name":"DB::Statement","name":"Statement"}],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":"Common interface for connection based statements\nand for connection pool statements.","summary":"

Common interface for connection based statements and for connection pool statements.

","class_methods":[],"constructors":[],"instance_methods":[{"id":"exec(args:Array):ExecResult-instance-method","html_id":"exec(args:Array):ExecResult-instance-method","name":"exec","doc":"See `QueryMethods#exec`","summary":"

See QueryMethods#exec

","abstract":true,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":"Array"}],"args_string":"(args : Array) : ExecResult","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L32","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L32","def":{"name":"exec","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":"Array"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"ExecResult","visibility":"Public","body":""}},{"id":"exec:ExecResult-instance-method","html_id":"exec:ExecResult-instance-method","name":"exec","doc":"See `QueryMethods#exec`","summary":"

See QueryMethods#exec

","abstract":true,"args":[],"args_string":" : ExecResult","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L28","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L28","def":{"name":"exec","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"ExecResult","visibility":"Public","body":""}},{"id":"exec(*args):ExecResult-instance-method","html_id":"exec(*args):ExecResult-instance-method","name":"exec","doc":"See `QueryMethods#exec`","summary":"

See QueryMethods#exec

","abstract":true,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args) : ExecResult","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L30","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L30","def":{"name":"exec","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"ExecResult","visibility":"Public","body":""}},{"id":"query(*args,&block)-instance-method","html_id":"query(*args,&block)-instance-method","name":"query","doc":"See `QueryMethods#query`","summary":"

See QueryMethods#query

","abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args, &block)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L22","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L22","def":{"name":"query","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":null,"splat_index":0,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"rs = query(*args)\nbegin\n yield rs\nensure\n rs.close\nend\n"}},{"id":"query(args:Array):ResultSet-instance-method","html_id":"query(args:Array):ResultSet-instance-method","name":"query","doc":"See `QueryMethods#query`","summary":"

See QueryMethods#query

","abstract":true,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":"Array"}],"args_string":"(args : Array) : ResultSet","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L39","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L39","def":{"name":"query","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":"Array"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"ResultSet","visibility":"Public","body":""}},{"id":"query:ResultSet-instance-method","html_id":"query:ResultSet-instance-method","name":"query","doc":"See `QueryMethods#query`","summary":"

See QueryMethods#query

","abstract":true,"args":[],"args_string":" : ResultSet","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L35","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L35","def":{"name":"query","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"ResultSet","visibility":"Public","body":""}},{"id":"query(*args):ResultSet-instance-method","html_id":"query(*args):ResultSet-instance-method","name":"query","doc":"See `QueryMethods#query`","summary":"

See QueryMethods#query

","abstract":true,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args) : ResultSet","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L37","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L37","def":{"name":"query","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"ResultSet","visibility":"Public","body":""}},{"id":"scalar(*args)-instance-method","html_id":"scalar(*args)-instance-method","name":"scalar","doc":"See `QueryMethods#scalar`","summary":"

See QueryMethods#scalar

","abstract":false,"args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"args_string":"(*args)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L11","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/statement.cr#L11","def":{"name":"scalar","args":[{"name":"args","doc":null,"default_value":"","external_name":"args","restriction":""}],"double_splat":null,"splat_index":0,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"query(*args) do |rs|\n rs.each do\n return rs.read\n end\nend\nraise(\"no results\")\n"}}],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/StringKeyCache","path":"DB/StringKeyCache.html","kind":"class","full_name":"DB::StringKeyCache(T)","name":"StringKeyCache","abstract":false,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/string_key_cache.cr","line_number":2,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/string_key_cache.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":null,"summary":null,"class_methods":[],"constructors":[],"instance_methods":[{"id":"clear-instance-method","html_id":"clear-instance-method","name":"clear","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/string_key_cache.cr#L17","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/string_key_cache.cr#L17","def":{"name":"clear","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@cache.clear"}},{"id":"each_value(&block)-instance-method","html_id":"each_value(&block)-instance-method","name":"each_value","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"(&block)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/string_key_cache.cr#L11","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/string_key_cache.cr#L11","def":{"name":"each_value","args":[],"double_splat":null,"splat_index":null,"yields":1,"block_arg":null,"return_type":"","visibility":"Public","body":"@cache.each do |_, value|\n yield value\nend"}},{"id":"fetch(key:String,&block):T-instance-method","html_id":"fetch(key:String,&block):T-instance-method","name":"fetch","doc":null,"summary":null,"abstract":false,"args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"String"}],"args_string":"(key : String, &block) : T","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/string_key_cache.cr#L5","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/string_key_cache.cr#L5","def":{"name":"fetch","args":[{"name":"key","doc":null,"default_value":"","external_name":"key","restriction":"String"}],"double_splat":null,"splat_index":null,"yields":0,"block_arg":null,"return_type":"T","visibility":"Public","body":"value = @cache.fetch(key, nil)\nif value\nelse\n value = @cache[key] = yield\nend\nvalue\n"}}],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/TopLevelTransaction","path":"DB/TopLevelTransaction.html","kind":"class","full_name":"DB::TopLevelTransaction","name":"TopLevelTransaction","abstract":false,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/DB/Transaction","kind":"class","full_name":"DB::Transaction","name":"Transaction"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/DB/Transaction","kind":"class","full_name":"DB::Transaction","name":"Transaction"},{"html_id":"github.com/crystal-lang/crystal-db/DB/BeginTransaction","kind":"module","full_name":"DB::BeginTransaction","name":"BeginTransaction"},{"html_id":"github.com/crystal-lang/crystal-db/DB/Disposable","kind":"module","full_name":"DB::Disposable","name":"Disposable"},{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/transaction.cr","line_number":38,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[],"extended_modules":[],"subclasses":[],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":null,"summary":null,"class_methods":[],"constructors":[{"id":"new(connection:Connection)-class-method","html_id":"new(connection:Connection)-class-method","name":"new","doc":null,"summary":null,"abstract":false,"args":[{"name":"connection","doc":null,"default_value":"","external_name":"connection","restriction":"Connection"}],"args_string":"(connection : Connection)","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L43","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L43","def":{"name":"new","args":[{"name":"connection","doc":null,"default_value":"","external_name":"connection","restriction":"Connection"}],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"_ = allocate\n_.initialize(connection)\nif _.responds_to?(:finalize)\n ::GC.add_finalizer(_)\nend\n_\n"}}],"instance_methods":[{"id":"begin_transaction:Transaction-instance-method","html_id":"begin_transaction:Transaction-instance-method","name":"begin_transaction","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : Transaction","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L62","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L62","def":{"name":"begin_transaction","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Transaction","visibility":"Public","body":"if @nested_transaction\n raise(DB::Error.new(\"There is an existing nested transaction in this transaction\"))\nend\n@nested_transaction = true\ncreate_save_point_transaction(self)\n"}},{"id":"commit-instance-method","html_id":"commit-instance-method","name":"commit","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L48","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L48","def":{"name":"commit","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@connection.perform_commit_transaction\nsuper()\n"}},{"id":"connection:DB::Connection-instance-method","html_id":"connection:DB::Connection-instance-method","name":"connection","doc":null,"summary":null,"abstract":false,"args":[],"args_string":" : DB::Connection","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L39","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L39","def":{"name":"connection","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@connection"}},{"id":"rollback-instance-method","html_id":"rollback-instance-method","name":"rollback","doc":null,"summary":null,"abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L53","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L53","def":{"name":"rollback","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"@connection.perform_rollback_transaction\nsuper()\n"}}],"macros":[],"types":[]},{"html_id":"github.com/crystal-lang/crystal-db/DB/Transaction","path":"DB/Transaction.html","kind":"class","full_name":"DB::Transaction","name":"Transaction","abstract":true,"superclass":{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},"ancestors":[{"html_id":"github.com/crystal-lang/crystal-db/DB/BeginTransaction","kind":"module","full_name":"DB::BeginTransaction","name":"BeginTransaction"},{"html_id":"github.com/crystal-lang/crystal-db/DB/Disposable","kind":"module","full_name":"DB::Disposable","name":"Disposable"},{"html_id":"github.com/crystal-lang/crystal-db/Reference","kind":"class","full_name":"Reference","name":"Reference"},{"html_id":"github.com/crystal-lang/crystal-db/Object","kind":"class","full_name":"Object","name":"Object"}],"locations":[{"filename":"db/transaction.cr","line_number":14,"url":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr"}],"repository_name":"github.com/crystal-lang/crystal-db","program":false,"enum":false,"alias":false,"aliased":"","const":false,"constants":[],"included_modules":[{"html_id":"github.com/crystal-lang/crystal-db/DB/BeginTransaction","kind":"module","full_name":"DB::BeginTransaction","name":"BeginTransaction"},{"html_id":"github.com/crystal-lang/crystal-db/DB/Disposable","kind":"module","full_name":"DB::Disposable","name":"Disposable"}],"extended_modules":[],"subclasses":[{"html_id":"github.com/crystal-lang/crystal-db/DB/SavePointTransaction","kind":"class","full_name":"DB::SavePointTransaction","name":"SavePointTransaction"},{"html_id":"github.com/crystal-lang/crystal-db/DB/TopLevelTransaction","kind":"class","full_name":"DB::TopLevelTransaction","name":"TopLevelTransaction"}],"including_types":[],"namespace":{"html_id":"github.com/crystal-lang/crystal-db/DB","kind":"module","full_name":"DB","name":"DB"},"doc":"Transactions should be started from `DB#transaction`, `Connection#transaction`\nor `Connection#begin_transaction`.\n\nUse `Transaction#connection` to submit statements to the database.\n\nUse `Transaction#commit` or `Transaction#rollback` to close the ongoing transaction\nexplicitly. Or refer to `BeginTransaction#transaction` for documentation on how to\nuse `#transaction(&block)` methods in `DB` and `Connection`.\n\nNested transactions are supported by using sql `SAVEPOINT`. To start a nested\ntransaction use `Transaction#transaction` or `Transaction#begin_transaction`.\n","summary":"

Transactions should be started from DB#transaction, Connection#transaction or Connection#begin_transaction.

","class_methods":[],"constructors":[],"instance_methods":[{"id":"commit-instance-method","html_id":"commit-instance-method","name":"commit","doc":"commits the current transaction","summary":"

commits the current transaction

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L21","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L21","def":{"name":"commit","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"close!"}},{"id":"connection:Connection-instance-method","html_id":"connection:Connection-instance-method","name":"connection","doc":null,"summary":null,"abstract":true,"args":[],"args_string":" : Connection","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L18","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L18","def":{"name":"connection","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"Connection","visibility":"Public","body":""}},{"id":"release_from_nested_transaction-instance-method","html_id":"release_from_nested_transaction-instance-method","name":"release_from_nested_transaction","doc":null,"summary":null,"abstract":true,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L35","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L35","def":{"name":"release_from_nested_transaction","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":""}},{"id":"rollback-instance-method","html_id":"rollback-instance-method","name":"rollback","doc":"rollbacks the current transaction","summary":"

rollbacks the current transaction

","abstract":false,"args":[],"args_string":"","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L26","source_link":"https://github.com/crystal-lang/crystal-db/blob/790b587e3fdf7678743c7bc0e96d5878f82baebe/src/db/transaction.cr#L26","def":{"name":"rollback","args":[],"double_splat":null,"splat_index":null,"yields":null,"block_arg":null,"return_type":"","visibility":"Public","body":"close!"}}],"macros":[],"types":[]}]}]}}