mirror of
				https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
				synced 2024-08-15 00:53:38 +00:00 
			
		
		
		
	Add fix for #600
This commit is contained in:
		
							parent
							
								
									c34a24b633
								
							
						
					
					
						commit
						5fd3ed782f
					
				
					 1 changed files with 38 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -225,3 +225,41 @@ class HTTP::Client
 | 
			
		|||
    response
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# https://github.com/will/crystal-pg/pull/171
 | 
			
		||||
class PG::Statement < ::DB::Statement
 | 
			
		||||
  protected def perform_query(args : Enumerable) : ResultSet
 | 
			
		||||
    params = args.map { |arg| PQ::Param.encode(arg) }
 | 
			
		||||
    conn = self.conn
 | 
			
		||||
    conn.send_parse_message(@sql)
 | 
			
		||||
    conn.send_bind_message params
 | 
			
		||||
    conn.send_describe_portal_message
 | 
			
		||||
    conn.send_execute_message
 | 
			
		||||
    conn.send_sync_message
 | 
			
		||||
    conn.expect_frame PQ::Frame::ParseComplete
 | 
			
		||||
    conn.expect_frame PQ::Frame::BindComplete
 | 
			
		||||
    frame = conn.read
 | 
			
		||||
    case frame
 | 
			
		||||
    when PQ::Frame::RowDescription
 | 
			
		||||
      fields = frame.fields
 | 
			
		||||
    when PQ::Frame::NoData
 | 
			
		||||
      fields = nil
 | 
			
		||||
    else
 | 
			
		||||
      raise "expected RowDescription or NoData, got #{frame}"
 | 
			
		||||
    end
 | 
			
		||||
    ResultSet.new(self, fields)
 | 
			
		||||
  rescue IO::Error
 | 
			
		||||
    raise DB::ConnectionLost.new(connection)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  protected def perform_exec(args : Enumerable) : ::DB::ExecResult
 | 
			
		||||
    result = perform_query(args)
 | 
			
		||||
    result.each { }
 | 
			
		||||
    ::DB::ExecResult.new(
 | 
			
		||||
      rows_affected: result.rows_affected,
 | 
			
		||||
      last_insert_id: 0_i64 # postgres doesn't support this
 | 
			
		||||
    )
 | 
			
		||||
  rescue IO::Error
 | 
			
		||||
    raise DB::ConnectionLost.new(connection)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue