Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

army-negative

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

army-negative

  • 3.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= Army::Negative -- Negative ones for true!

This gem is a simple ActiveRecord MySQL (+ARMy+) connection adapter monkey-patch. Put it in your +Gemfile+ and all your +true+ are belong to us! Or, rather, they'll suddenly become very negative, negative one specifically.

== Versioning

In general, army-negative versions are pinned to the supported rails version. Specifically, the major and minor version numbers will always match.

So, to use army-negative in a rails app, you'd use a version specifier in its entry in your +Gemfile+.

Examples:

gem "army-negative", "> 3.0.0" # for all rails 3.0.x apps gem "army-negative", "> 3.1.0" # for all rails 3.1.x apps gem "army-negative", "~> 4.5.6" # would work in any rails 4.5.x app

etc.

The exception to this rule is in rails 2.3.x apps (the oldest supported rails version). For these versions, you should use the latest 2.x version of army-negative (see the rails2 branch in the git repo).

== Usage

Simply put a line like the following in your +Gemfile+:

gem "army-negative", "~> 3.1.0"

Then do a bundle install on the command-line and you're set.

== What This Does

This makes ActiveRecord store the value -1 into your +TINYINT+ +boolean+ columns whenever they're set to +true+. It also makes ActiveRecord recognize -1 as +true+ when a +boolean+ field is queried.

NOTE: positive one and all other values that were interpreted as +true+ by the MySQL connection adapter will still be recognized as +true+ too.

== Why

This was written for a rails application that needed to access a legacy MySQL database. The new application needed to work concurrently with the existing (old) application, following its conventions.

The old application is a Microsoft Access 2003 program that uses the "linked tables" feature to store the data in a MySQL database. Microsoft's Visual Basic for Applications (VBA) stores +true+ values in memory with all bits turned on. If interpreted as an integer using two's complement, this is negative one. So the old application stores all our +true+ values as negative one. Because of this, many of the hand-written legacy queries also write and expect to read true values as negative one.

== The Name

Though no one besides myself is likely to see or use this gem, I still wanted to push it out to the public for posterity. The +ar+ in ARmy is for ActiveRecord while the +my+ in arMy is for MySQL. I'm sure you can guess what negative is supposed to reference.

== Authors and Credits

Authors:: Kendall Gifford

== License

Licensed using the standard {MIT License}[http://en.wikipedia.org/wiki/MIT_License]. See the file {LICENSE}[http://github.com/zettabyte/army-negative/blob/master/LICENSE] in the root folder of the project.

FAQs

Package last updated on 14 Sep 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc