Coder Social home page Coder Social logo

activerecord-analyze's Introduction

Rails and PostgreSQL Performance Consultant

Full Stack web development consultant with over 9 years of experience. Founder of Abot for Slack. Specializing in Ruby on Rails, PostgreSQL and website performance. Experienced in building scalable APIs for startups and refactoring legacy codebases. I'm blogging about web development related topics. After hours I train rock climbing to rest my wrists from the keyboard.

I'm currently available for ad hoc Rails performance consulting sessions.

activerecord-analyze's People

Contributors

andy9822 avatar bf4 avatar pawurb avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

activerecord-analyze's Issues

Build prefix method fails on `analyze:false` when there's also a format `fmt` option

build_prefix doesn't return a correct prefix when we passeanalyze: false + some fmt
format option.

def self.build_prefix(opts = {})
format_sql = if fmt = opts[:format].presence
case fmt
when :json
"FORMAT JSON, "
when :hash
"FORMAT JSON, "
when :pretty_json
"FORMAT JSON, "
when :yaml
"FORMAT YAML, "
when :text
"FORMAT TEXT, "
when :xml
"FORMAT XML, "
else
""
end
end
verbose_sql = if opts[:verbose] == true
", VERBOSE"
end
costs_sql = if opts[:costs] == true
", COSTS"
end
settings_sql = if opts[:settings] == true
", SETTINGS"
end
buffers_sql = if opts[:buffers] == true
", BUFFERS"
end
timing_sql = if opts[:timing] == true
", TIMING"
end
summary_sql = if opts[:summary] == true
", SUMMARY"
end
analyze_sql = if opts[:analyze] == false
""
else
"ANALYZE"
end
opts_sql = "(#{format_sql}#{analyze_sql}#{verbose_sql}#{costs_sql}#{settings_sql}#{buffers_sql}#{timing_sql}#{summary_sql})"
.strip.gsub(/\s+/, " ")
.gsub(/\(\s?\s?\s?,/, "(")
.gsub(/\s,\s/, " ")
.gsub(/\(\s?\)/, "")
end

This is caused because the format options adds a , (comma) right at the end the format option string.

However, when analyze is false an empty string "" is returned, therefore causing to have a comma followed by a whitespace and the closing parenthesis: , )

analyze_sql = if opts[:analyze] == false
""

This causes something like
image
which causes an invalid SQL query to be built

Thank you :-)

I want to say thank you for sharing your library with the world. I found it when I was looking for guidance on how to write a gem that extended ActiveRecord.

I used your gem as a template for how to structure the gem and it worked perfectly. Keep up the good work ๐Ÿ‘

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.