Giter VIP home page Giter VIP logo

crystal-cassandra's People

Contributors

kalinon avatar kaukas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

kalinon

crystal-cassandra's Issues

Setting consistency does not work

Hello,

I am trying to execute the following statements:

stmt = <<-CQL
  begin batch
    insert into #{@tbl_customer} (team_id) values (?) if not exists
    update #{@tbl_customer} set customer_id = ?, created_at = ? where team_id = ?
  apply batch
CQL

@db.exec stmt, team_id, cust_id, now, team_id

However, I am getting the following error when @db.exec executes:

ErrorServerProtocolError: Consistency level for LWT is missing for a request with conditions

To fix this, I am trying to set consistency level like this:

Cassandra::LibCass.execution_profile_set_consistency(profile, Cassandra::LibCass::CassConsistency::ConsistencyAny)
Cassandra::LibCass.execution_profile_set_serial_consistency(profile, Cassandra::LibCass::CassConsistency::ConsistencySerial)

stmt = <<-CQL
  begin batch
    insert into #{@tbl_customer} (team_id) values (?) if not exists
    update #{@tbl_customer} set customer_id = ?, created_at = ? where team_id = ?
  apply batch
CQL

@db.exec stmt, team_id, cust_id, now, team_id

However, seeing consistency in the profile does not seem to make any difference.

cc: @kaukas

Crystal 0.36.0 breaks this library

Hello,

Just upgraded to Crystal 0.36.0 and seeing the following error when trying to compile the project:

In lib/cassandra/src/cassandra/dbapi/session.cr:9:5

 9 | class Session < DB::Connection
     ^
Error: abstract `def DB::Connection#build_prepared_statement(query)` must be implemented by Cassandra::DBApi::Session

UDT erroring

Hello,
I'm getting an error on a user defined frozen hash field. The error is:

Unhandled exception: Missing hash key: ValueTypeUdt (KeyError)
  from /usr/lib/crystal/hash.cr:1027:11 in '[]'
  from lib/cassandra/src/cassandra/dbapi/decoders.cr:47:11 in 'get_decoder'
  from lib/cassandra/src/cassandra/dbapi/decoders.cr:297:11 in 'decode_with_type'
  from lib/cassandra/src/cassandra/dbapi/decoders.cr:13:13 in 'decode'
  from lib/cassandra/src/cassandra/dbapi/result_set.cr:126:9 in 'read'
  from lib/db/src/db/result_set.cr:79:15 in 'read'
  from src/ip-affinities.cr:17:18 in '__crystal_main'
  from /usr/lib/crystal/crystal/main.cr:105:5 in 'main_user_code'
  from /usr/lib/crystal/crystal/main.cr:91:7 in 'main'
  from /usr/lib/crystal/crystal/main.cr:114:3 in 'main'
  from __libc_start_main
  from _start
  from ???

The actual field causing the issue is defined as:
site_sections map<text, frozen<engagement_data>>,

engagement_data is defined as:

create type engagement_data (
	first_seen timestamp,
	last_seen timestamp,
	blink_total int,
	scan_total int,
	read_total int,
	score float,
	total_seconds int,
	total_read_seconds int
);

We have a lot of these nested custom types. Is there any way to allow them? Sorry if I'm missing something apparent, I'm also a crystal newb. The actual crystal code causing the issue is:

def get_sections(db, did)
  db.query("select did, site_sections from users where did=?", did) do |res|
    res.each do
      did = res.read(String)
      sections = res.read(Any)
      yield sections
    end
  end
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.